Redirect in vhost - bug

Discussion in 'Installation/Configuration' started by Poliman, May 26, 2018.

  1. Poliman

    Poliman Member

    I use newest ISP 3.1.11. I have created alias domain (vhost) which is additionally redirected to specific subdirectory. After set this redirection I provide LE SSL - works perfect. Finally I created redirection from http to https using checkbox in Redirect tab. Unfortunately redirect didn't work. Code (part of course, I can paste whole file if needed) in vhost looks like below:
    Code:
                    <IfModule mod_proxy_fcgi.c>
                            #ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ unix:///var/lib/php7.0-fpm/web93.sock|fcgi://localhost//var/www/clients/client5/web8/web/$1
                            <Directory /var/www/clients/client5/web8/web>
                                    <FilesMatch "\.php[345]?$">
                                                    SetHandler "proxy:unix:/var/lib/php7.0-fpm/web93.sock|fcgi://localhost"
                                    </FilesMatch>
                            </Directory>
                            </IfModule>
    
    
                    RewriteEngine on
                    RewriteCond %{REQUEST_URI} ^/\.well-known/acme-challenge/
                    RewriteRule ^ - [END]
            RewriteCond %{HTTPS} off
                    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
    
                    RewriteCond %{HTTP_HOST}   ^konkurs-podajdalej\.pl$ [NC]
                                    RewriteCond %{REQUEST_URI} !^/webdav/
                    RewriteCond %{REQUEST_URI} !^/php5-fcgi/
                    RewriteCond %{REQUEST_URI} !^/podaj_dalej/public/dist/
    
                    RewriteRule   ^/(.*)$ /podaj_dalej/public/dist/$1  [L]
    
                    RewriteCond %{HTTP_HOST}   ^www\.konkurs-podajdalej\.pl$ [NC]
                                    RewriteCond %{REQUEST_URI} !^/webdav/
                    RewriteCond %{REQUEST_URI} !^/php5-fcgi/
                    RewriteCond %{REQUEST_URI} !^/podaj_dalej/public/dist/
    
                    RewriteRule   ^/(.*)$ /podaj_dalej/public/dist/$1  [L]
    
            #RewriteCond %{HTTPS} off
                    #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
    
                    # add support for apache mpm_itk
                    <IfModule mpm_itk_module>
                            AssignUserId web8 client5
    
    ISP after checking redirect http to https checkbox adds line (without comments of course):
    Code:
            #RewriteCond %{HTTPS} off
                    #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
    
    but this does not work. I have to comment it and after some googing I found out that this redirect line should be before each rewrite rule. As you can see above I pasted this same part of code few lines higher. After reloading apache redirect from http to https works perfect. :) I think first should be redirect to https and then to specific subdirectory.
     

Share This Page