2012-10-07 57 views
2

我的主要領域是一個WordPress的博客,並重寫的.htaccess它是如下...的.htaccess重寫conditition忽略子域

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 
    </IfModule> 

這個偉大的工程,但我必須在同一目錄下的子域,並正在使用此重寫...

RewriteCond %{SERVER_PORT} ^443$ 
    RewriteCond %{HTTP_HOST} ^my\.domain\.com$ [NC] 
    RewriteCond %{REQUEST_URI} !^/my/ 
    RewriteRule ^(.*) /my/$1 

這是我的通配符SSL證書。這很好,但如果該位置不存在於子域中,我會得到wordpress的錯誤頁面。我需要wordpress重寫來忽略「我的」子域。我怎樣才能做到這一點?

我想這樣....

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_URI} !^my\.domain\.com$ 
    RewriteRule . /index.php [L] 
    </IfModule> 

但是,這並不工作,也試過這個....

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^my\.domain\.com - [L,NC] 
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 
    </IfModule> 

任何想法?

回答

5

您應該通過在服務器名稱上添加條件來忽略該域。

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteCond %{SERVER_NAME} !^my\.domain\.com 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 
</IfModule> 

而且,我前一段時間掙扎的事情,請嘗試更改子域的htaccess的,以

RewriteBase /my 

如果「我」將是它生活在目錄中。