【发布时间】:2012-06-30 13:33:14
【问题描述】:
我想将我所有的 http 流量重定向到我网站中的 https。
我的 .htaccess 文件中有以下代码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
当我将此文件放在目录中时,我收到一条错误消息,提示“此网页具有重定向循环 htaccess”
我看不到导致任何重定向的任何其他文件。
我该怎么办?
【问题讨论】:
-
它是否适用于这个 RewriteRule?
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 -
我复制了你的确切代码,它工作正常。您的
.htaccess文件中还有其他规则吗? -
你在更高的目录中有
.htaccess文件吗? -
在rewriting http to https 上查看此内容,但建议您使用
mod_alias代替Redirect to https。 -
试试
RewriteCond %{HTTPS} !=onRewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]