本文 15875 pv
1
下面是我网站的设置参数:
利用.htaccess绑定域名到子目录
© kekehu / 技术资源 / 2008.03.31 / 09:11 / 15875PV
注意:比如服务器上面有两个网站,第一个网站也有.htaccess文件,第二个网站也有.htaccess文件,而www.geekso.com打开的是第一个网站,要想让shop.geekso.com打开第二个网站,那么要把下面的代码写在第一个网站的.htaccess文件当中RewriteEngine on
# 把 yourdomain.com 改为你要绑定的域名.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# 把 subfolder 改为要绑定的目录.
RewriteCond %{REQUEST_URI} !^/subfolder/
# 不要改以下两行.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 把 subfolder 改为要绑定的目录.
RewriteRule ^(.*)$ /subfolder/$1
# 把 yourdomain.com 改为你要绑定的域名
# 把 subfolder 改为要绑定的目录.
# subfolder/ 后面是首页文件index.php, index.html......
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
# 把 yourdomain.com 改为你要绑定的域名.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# 把 subfolder 改为要绑定的目录.
RewriteCond %{REQUEST_URI} !^/subfolder/
# 不要改以下两行.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# 把 subfolder 改为要绑定的目录.
RewriteRule ^(.*)$ /subfolder/$1
# 把 yourdomain.com 改为你要绑定的域名
# 把 subfolder 改为要绑定的目录.
# subfolder/ 后面是首页文件index.php, index.html......
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
下面是我网站的设置参数:
RewriteCond %{HTTP_HOST} ^(shop.)?shop.geekso.com$
RewriteCond %{REQUEST_URI} !^/cctv/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cctv/$1
RewriteCond %{HTTP_HOST} ^(shop.)?shop.geekso.com$
RewriteRule ^(/)?$ cctv/index.php [L]
RewriteCond %{REQUEST_URI} !^/cctv/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cctv/$1
RewriteCond %{HTTP_HOST} ^(shop.)?shop.geekso.com$
RewriteRule ^(/)?$ cctv/index.php [L]
2011.08.14 06:55