2017-02-17 5 views
1

サブドメインのリダイレクトに問題があります。htaccess subdomainからリダイレクト

現在のリダイレクト:サブドメインの作業罰金から

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

ありがとう、1つのRewriteCondに対して複数の書き換えを使用することはできません。 – Nefro

+0

はい、可能です。私は答え –

+0

を更新しましたが、私は50以上の書き換えをしており、リダイレクトページは古いものと一致しないことがあります。 – Nefro

関連する問題