Answer the question
In order to leave comments, you need to log in
How to save protocol during redirect?
The task is seemingly simple, to save the protocol when redirecting. But there is no standard method.
Given:
RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP:X-Forwarded-Proto} http(s) [NC]
#RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^331/$ /best/http%1/%2/3 [L,R=301]
Answer the question
In order to leave comments, you need to log in
RewriteCond %{ENV:HTTPS} on
RewriteRule .* - [E=SSL:s]
RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]
RewriteRule ^(.*)$ http%{ENV:SSL}://www.%{HTTP_HOST}/$1 [R=301,L]
Alternatively, something likeRewriteCond %{HTTP:X-Forwarded-Proto} http(s) [NC] #RewriteCond %{HTTP_HOST} ^www\.(.*) [NC] RewriteRule ^331/$ /best/http%1/%2/3 [L,R=301]
%1 works with the comment, but not with the second cond ;(
!
will not overwrite the results of the previous one.RewriteCond %{HTTP:X-Forwarded-Proto} http(s)| [NC]
RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]
RewriteRule ^(.*)$ http%1://www.%{HTTP_HOST}/$1 [R=301,L]
s on site.ru
s on www.site.ru
s off site.ru
s off www.site.ru
RewriteCond "s-%{HTTPS} %{HTTP_HOST}" "^(?:(s)-on|\S+) (?!www\.)(.*)" [NC]
RewriteRule ^(.*)$ http%1://www.%2/$1 [R=301,L]
RewriteCond "s-%{HTTPS} %{HTTP_HOST}" "^(?:(s)-on|\S+) www\.(.*)" [NC]
RewriteRule ^(.*)$ http%1://%2/$1 [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question