.htaccess文件未将HTTP重定向到HTTPS

时间:2019-02-01 01:54:24

标签: .htaccess ssl redirect https

我刚刚从GoDaddy购买了UCC / SAN SSL证书,现在我正试图让我的网站(mannyrothman.com)自动从HTTP重定向到HTTPS。

这是我的“ .htaccess”文件的内容:

EditText

1 个答案:

答案 0 :(得分:0)

您可以使用此代码

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

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

,如果您想从https://ww.stackoverflow.com/重定向到https://stackoverflow.com/,也请使用此

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