[英]redirect http://www.domain.com to https://domain.com
[英]redirecting https://domain.com to https://www.domain.com
我最近将我的网站移至 HTTPS,我试图将所有 http 流量强制为 https 和 www。 版本
即强制https://domain.com到https://www.domain.com
我有这个在我的htaccess以及所有HTTP到https的作品,除了从重定向https://domain.com到https://www.domain.com
我究竟做错了什么?
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
你需要一个OR
条件:
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=301,L,NE]
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L,NE]
使用上述规则https://example.com没有重定向到https://www.example.com 。 为此,我也在 apache ssl vhost 块中添加了以下规则
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.exmple.com%{REQUEST_URI} [R=301,L,NE]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.