尝试将http重定向到https时,仅使用htaccess在safari中重定向循环

问题描述:

我不知道为什么会这样,但是当我使用野生动物园以外的任何其他浏览器访问我的网站时,它会将我重定向到https版本。但是,如果我使用野生动物园(在iPhone,Mac或iPad上)访问同一站点,则表示存在重定向循环。

I don't know why this is happening, but when I visit my site from any other browser other than safari, it redirects me to the https version. However, if I visit the same site using safari (on iPhone, mac, or iPad), it says there is a redirect loop.

我的htaccess代码:

My htaccess code:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Options -Indexes


</IfModule>

我不知道为什么会这样。非常感谢您的帮助。谢谢!

I don't know why this is happening. Any help is highly appreciated. Thanks!

我改用了此解决方案。

RewriteCond %{SERVER_PORT}  !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]