[英]redirecting https://domain.com to https://www.domain.com
I've recently moved my site to HTTPS and im trying to force all http traffic to https and also to the www.我最近将我的网站移至 HTTPS,我试图将所有 http 流量强制为 https 和 www。 version
版本
ie forcing https://domain.com to https://www.domain.com即强制https://domain.com到https://www.domain.com
I have this in my htaccess and all http to https works, apart from the redirect from https://domain.com to https://www.domain.com我有这个在我的htaccess以及所有HTTP到https的作品,除了从重定向https://domain.com到https://www.domain.com
What am i doing wrong?我究竟做错了什么?
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
You need an OR
condition here:你需要一个
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]
with the above rule https://example.com was not redirecting to https://www.example.com .使用上述规则https://example.com没有重定向到https://www.example.com 。 For that to happen I have added the following rule too in the apache ssl vhost block
为此,我也在 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.