如何将我的网站从所有HTTP请求redirect到使用www的HTTPS +非www HTTPS HTTPS?
例:
redirectHTTP非www,HTTP www。 &HTTPS非www:
HTTP:// example.com/ && HTTP:// www.example.com/ && HTTPS:// example.com/
一切以HTTPS与www:
HTTPS:// www.example.com/
# Redirect all "not correct" domain to www with https # (is not important if comes with or without https): RewriteCond %{HTTP_HOST} !^www.example.com$ [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] # Redirect all non-ssl to ssl. RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
我认为这将符合你的实际规则。
这将用于www或非www如果您尝试打开与www的链接,然后urlredirect到https与www
Example : http://domain.com redirect to https://domain.com
或者如果您尝试打开非www的链接,那么url会redirect到非www的https
Example : http://www.domain.com redirect to https://www.domain.com RewriteEngine on RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]