2011-11-30 71 views
1

我試圖子域重定向到子文件夾 我有3個指向一個名爲「測試」放置在根目錄(/試驗)重定向子域的子文件夾與htaccess的

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

是''
在這一行'重寫規則^ $(*)。 subdomain2/$ 1 [L,QSA]
'這裏的錯誤還是在你的htaccess文件中? –

+0

啊不是馬特它的拼寫錯誤我刪除它! –

回答

0

文件夾的子域我相信,500錯誤是因爲你沒有逃脫的網址您.

RewriteCond %{HTTP_HOST} ^subdomain1.mysite.com$ [NC] 

應該

RewriteCond %{HTTP_HOST} ^subdomain1\.mysite\.com$ [NC] 
+0

謝謝你Matt的幫助! 我試圖逃避的點,但仍然有相同的錯誤! 我的域名包含「 - 」是否意味着什麼? –

+0

htaccess被放置在文件夾「測試」,我把它放在根級別並更改RewriteBase? –

+0

將htaccess移到根目錄,並嘗試轉義連字符。 –

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] 

最後兩行:

RewriteCond %{HTTP_HOST} ^subdomain2.mysite.com$ [NC] 
RewriteRule ^(.*)$ subdomain3/$1 [L,QSA] 

subdomain2代替subdomain3

相關問題