Answer the question
In order to leave comments, you need to log in
How to make an exception in htaccess for https?
I am migrating a working site to the https protocol, but since the site is old, it does not work out to make it completely on https due to insecure content. There are pages like .../page/text.html in the urls, but there is no such folder physically - this is the htaccess rule that makes such a path. It turns out this code:
RewriteEngine On
RewriteBase /
RewriteRule ^page/(.*)$ page_redir.php?url=$1 [L]
RewriteCond %{REQUEST_URI} !^/page/.*$
RewriteCond %{HTTP_HOST} ^mysite\.com [NC]
RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Answer the question
In order to leave comments, you need to log in
RewriteCond %{HTTP_HOST} ^(www\.|)mysite\.com [NC
] - so it will be more accurate.
- everything is correct here as an option, remove the extra space before ! and make a softer condition, will it work?
Also, do not forget that html is, in theory, static, and can be picked up immediately by nginx and not reach the redirect in Apache in principle. Here you need more details about the server conf.
And also the whole .htaccess
and why do you needRewriteCond %{HTTP:X-Forwarded-Proto} ^http$
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question