利用.htaccess绑定域名到子目录

首先得把域名解析到主机的IP,其次是在网站管理面板里,为网站绑定域名,最后编辑配置.htaccess文件,就可以了。
下面是 .htaccess文件内容:

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

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

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

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

# 把 btoss.com 改为你要绑定的域名
# 把 text 改为要绑定的目录.
# text/ 后面是首页文件index.php, index.html
RewriteCond %{HTTP_HOST} ^(www.)?btoss.com$
RewriteRule ^(/)?$ text/index.php [L]

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Captcha Code