apache 服务器:https 下,如果想要强制test.com 跳转到www.test.com
由于https的原因,可以使用下面的方式:
RewriteCond %{HTTP_HOST} ^test.com [NC]
RewriteRule ^(.*)$ https://www.test.com/$1 [L,R=301]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://www.test.com/$1 [L,R=301]
先做www的强制跳转,再做https的跳转,就不会出现在https下跳转到www时无效;反之,想要跳转到无www同理