如何将所有访问者定向到https://www.example.com?

时间:2019-03-15 18:53:36

标签: url-redirection

我以为我做对了,但是当我在浏览器中键入example.com时,它没有重定向,则显示出无服务器IP错误。

我现在拥有的代码是:

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

欢呼

1 个答案:

答案 0 :(得分:0)

尝试一下:

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