非www重定向与https结合使用

时间:2012-11-27 16:40:34

标签: .htaccess https

我需要2次重定向。第一个是任何非https的请求都应该是https。第二个是任何非www应该是www。下面,https一个工作,但第二个没有,并在原始网址上添加。我需要这两个一致地工作

# Redirect non https to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

# redirect non www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

当它们都启用时,第二个在URL中重复两次http_host。

我需要的是mysite.com重定向到https://www.mysite.com以及http://www.mysite.com重定向到https://www.mysite.com

1 个答案:

答案 0 :(得分:0)

更新:清除缓存后,这有效。

相关问题