2013-10-15 201 views
0

基本上我有一個共享服務器與一個現有的網站和一個新的網站。在大多數共享主機(Linux)的我有,文件結構是這樣的:共享服務器上的兩個網站的htaccess配置

- public_html 
-- firstsite.com 
-- secondsite.com 

對於問題的服務器結構更像是這樣的:

- public_html 
-- all of the folders and files of the first site loose in this directory 
-- secondsite.com 

所以,如果我嘗試從瀏覽器訪問secondsite.com,我在這裏發送代替: http://firstsite.com/secondsite.com

......這顯然是不正確的。我的託管支持告訴我,如果我重新命名由firstsite.com使用的htaccess文件的secondsite.com會解決: http://secondsite.com

我明明只是不能禁用我的htaccess的文件,因爲這將博克的第一個站點。

所以我期待在我的htaccess的文件,並認爲這是有問題的行:

### Only allow access without the www. #### 
    RewriteCond %{HTTP_HOST} !^firstsite\.come$ [NC] 
    RewriteRule ^(.*)$ http://firstsite.com/$1 [R=301,L] 

我想我需要一組類似的,涉及到secondsite.com規則?

任何建議將是偉大的。

回答

0

首先你的RewriteRule將始終被執行,因爲你在RewriteCond有一個無效的域名,它將永遠不同於該主機(你有.come)。

其次,我認爲你可以嘗試在你的.htaccess file添加爲你的第一套規則:

RewriteCond %{HTTP_HOST} ^secondsite\.com$ [NC] 
RewriteRule ^(.*)$ /secondsite.com/$1 [QSA,L] 
0

您需要更改您的規則來自:

RewriteCond %{HTTP_HOST} !^firstsite\.come$ [NC] 
RewriteRule ^(.*)$ http://firstsite.com/$1 [R=301,L] 

要:

RewriteCond %{HTTP_HOST} ^www\.firstsite\.com$ [NC] 
RewriteRule ^(.*)$ http://firstsite.com/$1 [R=301,L] 

因此,當主機是secondsite.com時,規則不會嘗試紅色直接回到第一個site.com

相關問題