举例:
有多个域名:site1.haoduck.com
,site2.haoduck.com
,site3.haoduck.com
分别在二级目录site1.haoduck.com/
,site2.haoduck.com/
,site3.haoduck.com/
.htaccess的代码如下
- RewriteEngine On
- RewriteCond %{HTTP_HOST} ^site1.haoduck.com$
- RewriteCond %{REQUEST_URI} !^/site1.haoduck.com/
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ /site1.haoduck.com/$1
- RewriteCond %{HTTP_HOST} ^site1.haoduck.com$
- RewriteRule ^(/)?$ site1.haoduck.com/index.php [L]
- RewriteCond %{HTTP_HOST} ^site2.haoduck.com$
- RewriteCond %{REQUEST_URI} !^/site2.haoduck.com/
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ /site2.haoduck.com/$1
- RewriteCond %{HTTP_HOST} ^site2.haoduck.com$
- RewriteRule ^(/)?$ site2.haoduck.com/index.php [L]
- RewriteCond %{HTTP_HOST} ^site3.haoduck.com$
- RewriteCond %{REQUEST_URI} !^/site3.haoduck.com/
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ /site3.haoduck.com/$1
- RewriteCond %{HTTP_HOST} ^site3.haoduck.com$
- RewriteRule ^(/)?$ site3.haoduck.com/index.php [L]
THE END