我是htaccess的新手。 我的域将创建重定向循环。 我不知道为什么会这样。 这是代码
RewriteEngine on
AddHandler application/x-httpd-php5 .htm .php .html
IndexIgnore *
RewriteCond %{HTTP_HOST} ^domain'.com$ [OR]
RewriteCond %{HTTP_HOST} ^www'.domain'.com$
RewriteRule ^/?$ "https':'/'/domain'.com'/" [R=301,L]
相同的代码在几个月内工作正常,但现在突然它创建了重定向循环。 我不知道为什么会发生这种情况。
我希望该用户始终以https
而不是http
打开
请让我纠正此代码的错误。
为了将http://
重定向到https://
,您需要使用的重写规则是:
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}