【发布时间】:2019-07-09 23:51:33
【问题描述】:
我使用 Apache 服务器发布我的网站。问题是我想强制我的网站使用 HTTPS。例如,如果有人输入 URL“http://www.alireza.co/contact.html”,它应该重定向到“https://alireza.co/contact.html”。
我使用以下规则创建了一个.htaccess 文件:
# To use 404.html as default 404 error page.
ErrorDocument 404 /404.html
# To force website use https and remove www. subdomain.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://alireza.co/$1 [R=301,L]
现在的问题是每当我输入 URL 时,无论是使用 https 或 http,还是使用 www. 或没有它,我都会在 Firefox 中收到错误 too many redirects 或 the website is not redirecting properly。
我使用Autistici.org 作为我的主机提供商。我的网站是静态的(仅限 HTML/CSS)。我尝试了很多方法,但都没有成功。
【问题讨论】:
标签: apache .htaccess ssl https no-www