【问题标题】:Redirecting website to https将网站重定向到 https
【发布时间】:2017-10-02 12:14:51
【问题描述】:

我已经通过 123-Reg 获得了 SSL 证书,我已经批准了,现在 123-Reg 建议我必须更新我的 .htaccess 文件,以便将所有 http 请求重新路由到 https .

问题是每次我更新 .htaccess 时,网站都会宕机。

环顾四周,我似乎应该在 .htaccess 文件的顶部发布以下内容:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

所以,我当前的 .htaccess 文件如下所示:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 day"
ExpiresByType text/html "access 1 day"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 30 minutes"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
#Alternate default index page
DirectoryIndex index.php

我已经尝试过使用上面的代码,只是自己重写代码,但无济于事。应该注意的是,我对使用 .htaccess 的复杂性并不是特别熟悉!

我收到的错误消息(在 IE Edge 中)是:

Hmmm... cannot reach this page
Try this
Make sure that you’ve got the right web address: https://www.pixel8games.com
Search for "https://www.pixel8games.com" on Bing
Refresh the page
Details 
There were too many redirections.
Error Code: INET_E_REDIRECT_FAILED

当重定向代码不在 .htaccess 中时,我也可以在 url 中手动输入 https 地址而不会出现问题。

如果有人能提供帮助,我将不胜感激。 丹。

【问题讨论】:

    标签: apache .htaccess ssl redirect https


    【解决方案1】:

    清除浏览器缓存并输入以下代码:

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://yourdomain.com/$1 [L,R]
    

    【讨论】:

    • 嗨,不幸的是,这对我拥有的所有实例(IE Edge、Chrome 桌面和移动设备、Opera 和 Firefox)都没有帮助。他们都说网站重定向太多次了。
    • 查看更新,先清除浏览器缓存再测试
    • 是的,我按照您在帖子中提出的所有建议都做了,但很遗憾,问题仍然存在。
    猜你喜欢
    • 2013-07-03
    • 1970-01-01
    • 2015-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-22
    • 1970-01-01
    相关资源
    最近更新 更多