[英]forcing HTTPS with .htaccess resulting in redirect loop
I'm trying to force all users coming to my page access it through https. 我正试图强制所有访问我页面的用户通过https访问它。 I have googled a lot and found tons (mostly the same) .htaccess solutions but with all of them I get the "This webpage has a redirect loop Reload" in chrome and similar in firefox.
我已经google了很多,并发现吨(大多数相同).htaccess解决方案,但所有这些我得到“这个网页有一个重定向循环重新加载”铬和类似的Firefox。
This is what I have currently in my .htaccess file. 这就是我目前在.htaccess文件中的内容。
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Can anyone advise what the issue might be because I have no idea. 任何人都可以建议问题是什么,因为我不知道。
Thanks 谢谢
Try this rule: 试试这条规则:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} =80
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,NE,L]
Just make sure this is very first rule in your .htaccess file. 只需确保这是.htaccess文件中的第一条规则 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.