【发布时间】:2016-05-11 02:58:27
【问题描述】:
我不知道为什么会失败。我只想将所有域重定向到www.maindomain.com 和http 到https,我错过了什么?
# redirect http to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# redirect without www to www
RewriteCond %{http_host} ^maindomain.com [nc]
RewriteRule ^(.*)$ https://www.maindomain.com [r=301,nc]
# redirect another domain to www.maindomain.com
RewriteCond %{HTTPS} off # this i was missing
RewriteCond %{HTTP_HOST} ^(www\.)?anotherdomain.com [NC]
RewriteRule ^(.*)$ https://www.maindomain.com [R=301,L]
-
http://maindomain.com到https:/www.maindomain.com/有效 -
http://anotherdomain.com到https:/www.maindomain.com/有效 -
https://anotherdomain.com到https:/www.maindomain.com/失败
【问题讨论】:
-
奇怪,RewriteCond %{HTTPS} 关闭的评论,提示现在正在工作,但答案已被删除,就像我想接受它一样,我错过了第二个 RewriteCond第三次重定向
标签: apache .htaccess redirect ssl