有时要把域名解析到网站子目录里面,实现一个空间多网站,各个互不相影响。
通过配置.htaccess文件实现的方法:

RewriteEngine on
# 把 maoegg.com 改为你要绑定的域名.
RewriteCond %{HTTP_HOST} ^(www.)?maoegg.com$

# 把 xhot 改为要绑定的目录.
RewriteCond %{REQUEST_URI} !^/xhot/

# 不要改以下两行.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# 把 xhot 改为要绑定的目录.
RewriteRule ^(.*)$ /xhot/$1

# 把 maoegg.com 改为你要绑定的域名
# 把 xhot 改为要绑定的目录.
# xhot/ 后面是首页文件index.php, index.html……

RewriteCond %{HTTP_HOST} ^(www.)?maoegg.com$
RewriteRule ^(/)?$ xhot/index.php [L]


文章来源:毛蛋网(maoegg.com)