2017-02-17 173 views
1

我有問題,子域重定向。htaccess從子域重定向

當前重定向:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^sub.website.com$ 
RewriteRule ^any/other/page/$ http://website.com/sub/any/other/page/ [R=301,L,NC,QSA] 
RewriteRule ^blog/$ http://website.com/sub/blog/ [R=301,L,NC,QSA] 
..... and much more other rewriterule (50+) 

從子域做工精細重定向,但http://website.com/blog/也被重定向到http://website.com/sub/blog/

也許有人能找到這個問題?

P.S.在wordpress上使用,我的重定向在wordpress重定向之前寫過

回答

2

您有1個條件和2個規則。條件僅適用於最後一個條件之後的第一個重寫小節。你需要另一個與你使用它們的方式。

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^sub\.website\.com$ 
RewriteRule ^any/other/page/$ http://website.com/sub/any/other/page/ [R=301,L,NC,QSA] 
RewriteCond %{HTTP_HOST} ^sub\.website\.com$ 
RewriteRule ^blog/$ http://website.com/sub/blog/ [R=301,L,NC,QSA] 

根據您的評論。

如果你想鞏固你可以做到這一點。

RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^sub\.website\.com$ 
    RewriteRule ^(any/other/page|blog)/$ http://website.com/sub/$1/ [R=301,L,NC,QSA] 
+0

非常感謝,所以不可能爲一個RewriteCond使用多個rewriterules? – Nefro

+0

是的,這是可能的。我更新了答案 –

+0

,但我有50多個重寫過濾器,並且重定向頁面有時與舊的不匹配 – Nefro