举例:
有多个域名:site1.abc.com
,site2.abc.com
,site3.abc.com
分别在二级目录site1.abc.com/
,site2.abc.com/
,site3.abc.com/
.htaccess的代码如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| RewriteEngine On RewriteCond %{HTTP_HOST} ^site1.abc.com$ RewriteCond %{REQUEST_URI} !^/site1.abc.com/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /site1.abc.com/$1 RewriteCond %{HTTP_HOST} ^site1.abc.com$ RewriteRule ^(/)?$ site1.abc.com/index.php [L]
RewriteCond %{HTTP_HOST} ^site2.abc.com$ RewriteCond %{REQUEST_URI} !^/site2.abc.com/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /site2.abc.com/$1 RewriteCond %{HTTP_HOST} ^site2.abc.com$ RewriteRule ^(/)?$ site2.abc.com/index.php [L]
RewriteCond %{HTTP_HOST} ^site3.abc.com$ RewriteCond %{REQUEST_URI} !^/site3.abc.com/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /site3.abc.com/$1 RewriteCond %{HTTP_HOST} ^site3.abc.com$ RewriteRule ^(/)?$ site3.abc.com/index.php [L]
|