redirect - Apache directory trailing slash issue behind https -
i run apache server behind https portal , have issue directory redirection. apache server docker container receives requests forwarded https portal container (steveltn/https-portal). works fine, except default http redirections made http instead of https. instance, let have directory named test in apache website. calling https://example.com/test returns 301 code redirection http://example.com/test/. right behaviour have redirection https.
i first thought misconfiguration of https portal, , asked steveltn/https-portal team. replied it's problem in apache configuration (https://github.com/steveltn/https-portal/issues/67#issuecomment-257934618). summary of answer
portal tell apache existence request header x-forwarded-proto: https. web apps recognize header automatically, such wordpress. guess configure web app recognize header
i tried lot of configuration found on internet instance one, none fixes problem:
<virtualhost *:80> serveradmin webmaster@localhost documentroot /var/www/html errorlog ${apache_log_dir}/error.log customlog ${apache_log_dir}/access.log combined rewriteengine on rewritecond %{http:x-forwarded-proto} !https rewriterule (.*) https://%{http_host}%{request_uri} [r,l] </virtualhost>
if change rewritecond %{http:x-forwarded-proto} https, infinite redirection loop.
any idea ?
might have .htaccess file causes redirect?
if problem caused config above, try following:
rewriteengine on # add trailing slash directories rewritecond %{request_filename} !-f rewritecond %{request_uri} !(.*)/$ rewriterule ^(.*)$ $1/ [l,r=301] ## redirect https rewritecond %{http:x-forwarded-proto} !https rewriterule (.*) https://%{http_host}%{request_uri} [r,l]
Comments
Post a Comment