虚拟主机不支持子目录的情况下借助.htaccess实现多个域名重定向到子目录实现单空间多站点
mantou438人阅读
举例:
有多个域名: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]
评论 | 0 条评论
登录之后才可留言,前往登录