.htaccess 301跳转(裸域、WWW)

# Option 1: 把 “www.xiaokyun.com 转向裸域 xiaokyun.com”

#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# Option 2: 把 “domain.com 转向 www.xiaokyun.com”

#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www..+$ [NC]
#RewriteCond %{HTTP_HOST} (.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

#common configuration

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^xiaokyun.com
RewriteRule ^(.*)$ http://www.xiaokyun.com/$1 [R=301,L]
</IfModule>

Published by

@XiaoKyun

双鱼男,过分热心的好人。