Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html .htaccess此网页具有重定向循环htaccess_Html_Security_.htaccess - Fatal编程技术网

Html .htaccess此网页具有重定向循环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

我想在我的网站中将所有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 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,但仍然显示该错误。