Html .htaccess此网页具有重定向循环htaccess
我想在我的网站中将所有http流量重定向到https 我的.htaccess文件中有以下代码Html .htaccess此网页具有重定向循环htaccess,html,security,.htaccess,Html,Security,.htaccess,我想在我的网站中将所有http流量重定向到https 我的.htaccess文件中有以下代码 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} </IfModule> 重新启动发动机 重写条件%{HTTPS}关闭 重写规则^https://%{HTTP\u HOST}%{REQUEST\u
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
重新启动发动机
重写条件%{HTTPS}关闭
重写规则^https://%{HTTP\u HOST}%{REQUEST\u URI}
当我把这个文件放到一个目录中时,我收到一个错误,说“这个网页有一个重定向循环”
我看不到任何其他导致重定向的文件
我该怎么办?这会将端口80(标准http)上的所有流量重定向到https:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
或者,相反-重定向任何不在端口443(https)上的流量:
您也可以尝试:
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
这会将端口80(标准http)上的所有流量重定向到https:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
或者,相反-重定向任何不在端口443(https)上的流量:
您也可以尝试:
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
这个规则适用吗
RewriteRule^(.*)$https://%{HTTP_HOST}/$1
我复制了您的精确代码,它工作正常。您的.htaccess
文件中是否有任何其他规则?您在更高的目录中是否有.htaccess
文件?请参阅上的内容,但建议您改用mod_alias
。尝试重写cond%{HTTPS}=在
RewriteRule^/?(*)https://%{SERVER_NAME}/$1[R,L]
上它是否与此重写规则一起工作RewriteRule^(.*)$https://%{HTTP_HOST}/$1
我复制了您的精确代码,它工作正常。您的.htaccess
文件中是否有任何其他规则?您在更高的目录中是否有.htaccess
文件?请参阅上的内容,但建议您改用mod_alias
。尝试重写cond%{HTTPS}=在
RewriteRule^/?(*)https://%{SERVER_NAME}/$1[R,L]
上,如果查看注释,您将看到它正在重定向到https fine,但仍然显示该错误。如果查看注释,您将看到它正在重定向到https fine,但仍然显示该错误。