2013-07-15 94 views
1

我們有不同的域名託管在我們的服務器上。最近我們網站的主要部分之一已被移動到另一臺服務器和被賦予了子域:重定向路徑,但僅限特定域名

http://www.mysite.com/store 

已經移動到

http://store.mysite.com 

在我們的Apache VirtualHost我們想重定向所有交通舊域到新的一個:

Redirect permanent /store http://store.mysite.com 

的問題是,我們有其他託管網站,現在正在重新定向:

http://www.othersite.com/store 
http://api.greatsite.com/store 

我們不想要這個。我如何才能讓Apache重定向如果http://www.mysite.com/store其中有/store路徑,並忽略其他域與/store?基於

回答

2

使用mod_rewrite代碼:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC] 
RewriteRule ^/?store(/.*|)$ http://store.mysite.com [L,R=301,NC] 
+0

那麼,這條規則意味着只有重定向如果用戶正在訪問'www.mysite.com /存儲/ *'? –

+0

作出編輯,現在上面的規則將處理所有'www.mysite.com/store/*'URL。 – anubhava

+0

嗯,做了更改,但查看'http:// api.greatsite.com/store'仍然重定向到'http:// store.mysite.com',這是我不想要的。只有'www.mysite.com'應該。 –