我正在尝试将子域重定向到子文件夹 我有3个子域指向名为&#34的文件夹; test"放在根(/ test)
subdomain1.mysite.com
subdomain2.mysite.com
subdomain3.mysite.com
in test i have 3 folders `/test/subdomain1 , /test/subdomain2, /test/subdomain3`
what i want is that:
when i go to subdomain1.mysite.com it should be reading from: /test/subdomain1
when i go to subdomain2.mysite.com it should be reading from: /test/subdomain2
when i go to subdomain3.mysite.com it should be reading from: /test/subdomain3
here is my htaccess used - placed in the folder "/test" and i think here is the problem!!:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain1.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain1/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain2/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain3/$1 [L,QSA]
</IfModule>
i am getting a "500 Internal Server Error" when accessing any subdomain...
does RewriteBase works in subfolders ? if not placed the root ?
any idea?
thanks
答案 0 :(得分:0)
我认为500错误是因为您没有在网址中转义.
:
RewriteCond %{HTTP_HOST} ^subdomain1.mysite.com$ [NC]
应该是
RewriteCond %{HTTP_HOST} ^subdomain1\.mysite\.com$ [NC]
答案 1 :(得分:0)
有错误......
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain1.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain1/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain2/$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain3/$1 [L,QSA]
最后2行:
RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC]
RewriteRule ^(.*)$ subdomain3/$1 [L,QSA]
subdomain2而不是subdomain3