你可以在htaccess使用下列规则改写子域到子文件夹:
RewriteEngine On
#If the host is "sub.domain.com"
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC]
#Then rewrite any request to /folder
RewriteRule ^((?!folder).*)$ /folder/$1 [NC,L]
通过线解释线:
RewriteEngine on
线以上告诉服务器打开发动机重写URL。
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC]
这条线是一个条件的RewriteRule我们对阵HTTP主机使用正则表达式模式。条件说如果主机sub.domain.com然后execute的规则。
RewriteRule ^((?!folder).*)$ /folder/$1 [NC,L]
比赛的规则http:///sub.domain.com Foo内部重定向到http:/ / / / sub.domain.com foo文件夹
与你想点你的子域的子域和文件夹替换文件夹名称你sub.domain.com。
http://test.domain.com
/subdomains/test/
P
http://test.domain.com/subdomains/test/
test.domain.com/subdomains/test
RewriteEngine on
[P]