将http重定向到主要主页域的https

时间:2018-11-28 05:45:08

标签: .htaccess redirect

仅在主主页域中,如何编写从http到https的重定向链接?

Redirect example.com https://example.com
Redirect http://example.com https://example.com
Redirect http://www.example.com https://example.com
Redirect www.example.com https://example.com

要添加.htacess哪个是正确的?

1 个答案:

答案 0 :(得分:0)

尝试将HTTP重定向到HTTPS

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]