【发布时间】: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