由网友(演累る、⒐放扌吧)分享简介:我试图强制用户重定向到非www网站,并强制HTTPS。I'm trying to force a user to be redirected to the non-www website, and, force https.我这有哪种类型的工作,但并不强制HTTPS,时输入HTTP。 I've got this...
我试图强制用户重定向到非www网站,并强制HTTPS。
I'm trying to force a user to be redirected to the non-www website, and, force https.
我这有哪种类型的工作,但并不强制HTTPS,时输入HTTP。
I've got this which sort of work, but doesn't force https, when http is entered.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://site.com.net/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
这是我在做什么任何想法错了?
Any ideas on what I'm doing wrong?
推荐答案
试试这个规则:
RewriteCond %{HTTP_HOST} ^(www.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
相关推荐
最新文章