【发布时间】:2018-02-15 12:24:55
【问题描述】:
我有这个 .htaccess 文件将http:// 重定向到https://
我还做了www. 到根域重定向!
www. 到根域有效!但是https:// 重定向没有!
如果我将RewriteCond %{HTTPS} on 设置为RewriteCond %{HTTPS} off 或RewriteCond %{HTTPS} =!on,则会出现浏览器错误:
example.com 页面无法正常工作
mysite.com 重定向您的次数过多。
尝试清除您的 cookie。
ERR_TOO_MANY_REDIRECTS
我所做的一次编辑给了我一个 500 错误,但我将它恢复到以前的状态!我所做的只是改变:RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 到 RewriteRule(.*) https://%{HTTP_HOST}%{REQUEST_URI} 或 RewriteRule (.*)https://%{HTTP_HOST}%{REQUEST_URI}
有人对如何解决此问题有任何想法吗?
这是我的整个.htaccess 文件!
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://antimalwareprogram.co%{REQUEST_URI} [R=301,L,NE]
</IfModule>
【问题讨论】:
标签: apache .htaccess redirect mod-rewrite http-status-code-500