.htaccess绑定域名到子目录

在网站根目录下添加.htaccess


RewriteEngine On
RewriteCond %{HTTP_HOST} ^(blog\.)?xiaokyun\.com$
RewriteRule ^blog/(.*)$ http://blog.xiaokyun.com/$1 [L,QSA,R=301]
RewriteCond %{HTTP_HOST} ^blog\.xiaokyun\.com$
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule ^(.*)$ /blog/$1 [L,QSA]

在子目录下添加.htaccess

RewriteEngine On
RewriteBase /blog
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

Published by

@XiaoKyun

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