11月13
最近有个客户要http的301跳转到SSL的https网址,实现如下:
RewriteCond %{ENV:HTTPS} !^on$
RewriteCond %{HTTP:X-Sakura-Forwarded-For} ^$
RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
或者
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.hecks.tk/$1 [R=301,L]
或者
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
#301到www
RewriteCond %{HTTP_HOST} ^hecks.tk$ [NC]
RewriteRule ^(.*)$ https://www.hecks.tk/$1 [L,R=301]
#只跳http的80端口,https是443
RewriteCond %{HTTP_HOST} ^(hecks.tk)(:80)?
RewriteRule ^(.*) https://www.hecks.tk/$1 [R=301,L]
RewriteCond %{ENV:HTTPS} !^on$
RewriteCond %{HTTP:X-Sakura-Forwarded-For} ^$
RewriteRule . https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
或者
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.hecks.tk/$1 [R=301,L]
或者
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
#301到www
RewriteCond %{HTTP_HOST} ^hecks.tk$ [NC]
RewriteRule ^(.*)$ https://www.hecks.tk/$1 [L,R=301]
#只跳http的80端口,https是443
RewriteCond %{HTTP_HOST} ^(hecks.tk)(:80)?
RewriteRule ^(.*) https://www.hecks.tk/$1 [R=301,L]




