【问题标题】:Htaccess redirection to httpsHtaccess 重定向到 https
【发布时间】:2012-10-27 16:33:23
【问题描述】:

我正在使用以下 httaccess 内容,强制重写 url 以使用 https 而不是 http

RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [L]

但它总是越来越, 页面未正确重定向

Firefox has detected that the server is redirecting the request for this address
in a way that will never complete.     
This problem can sometimes be caused by disabling or refusing to accept
cookies.

我使用了许多其他解决方案,但总是得到这个......

【问题讨论】:

标签: php apache .htaccess https


【解决方案1】:

试试下面的 .htaccess 代码

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

#uncomment the below two line if you need to append www
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

【讨论】:

    猜你喜欢
    • 2022-01-11
    • 2021-11-10
    • 2012-12-23
    • 2020-07-11
    • 2016-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多