2016-07-08 6 views
1

このトピックに関してはここに他の質問がありますが、私は問題を克服するために使用できませんでした。ここでhtaccessはサブドメインと残りのトラフィックを処理します

は私がやろうとしていますものです:私たちは、ドメインの変更を持っていた、我々はsubdmainに独自のドメインからサイトを移動:

www.oldsite.com - >http://oldsite.newdomain.com

をもありました古いサブドメイン:それは単にR、しなかった場合、私は、最初のサブドメインがあった場合はキャッチし、それをリダイレクトすることによって、htaccessの中でこれを処理しようとしていたhttp://sub.newdomain.com

にする必要がある

http://sub.oldsite.comトラフィックの残りの部分をedirectします。

<IfModule mod_rewrite.c> 

#Send all traffic to store.newsite.com 
#RewriteCond %{HTTP_HOST} ^store.oldsite.com [NC,OR] 
#RewriteRule ^(.*)$ http://store.newsite.com/$1 [L,R=301,NC] 

#Sends all traffic to store.newsite.com 
#RewriteCond %{HTTP_HOST} !^store.oldsite.com$ [NC] 
#RewriteRule ^(.*)$ http://store.newsite.com/$1 [R=301,QSA,L] 

#Doesn't catch the sub domain and all redirects fall to the 301 
#RewriteCond %{HTTP_HOST} store.oldsite.com$ [NC] 
#RewriteRule ^(.*)$ http://store.newsite.com/$1 [P] 

#redirects all traffic, but not additional pages e.g. newsite.com/a/b/c 
#RewriteCond %{HTTP_HOST} ^oldsite.com [NC,OR] 
#RewriteCond %{HTTP_HOST} ^www.oldsite.com [NC] 
#RewriteRule ^(.*)$ http://newsite.com/$1 [L,R=301,NC] 

</IfModule> 

#redirects all traffic and the additonal params /a/b/c 
Redirect 301/http://newsite.com/ 

をルールのいずれかが満たされなかった場合には下部に301リダイレクトを残したまま、私は個別にこれらのすべてを試してみました:ここ

は、私がこれまで試してみましたものです。コードブロックの上のコメントは、私が受け取った結果を示します。私はhtaccessに精通しておらず、私が得ることができるあらゆる助けを使うことができます。前もって感謝します。私は何を期待

store.oldsite.com => store.newsite.com (this is the only sub domain) 

oldsite.com => newsite.com (All existing pages, could be up to 4/5 deep. e.g. oldsite.com/a/b/c/d => newsite.com/a/b/c/d) 

答えて

2

あなたはこのファイルを試すことができます:私はそれを試してみるよ

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteBase/

    #Redirect old store to new domain 
    RewriteCond %{HTTP_HOST} ^store\.oldsite\.com$ [NC] 
    RewriteRule ^(.*)$ http://store.newsite.com/$1 [L,R=301,NC] 

    #redirect old site (with or without www) to new domain 
    RewriteCond %{HTTP_HOST} ^(www\.|)oldsite\.com$ [NC] 
    RewriteRule ^(.*)$ http://newsite.com/$1 [L,R=301,NC] 

    #redirect others to new domain homepage 
    RewriteCond %{HTTP_HOST} oldsite\.com$ [NC] 
    RewriteRule ^.*$ http://newsite.com/? [L,R=301] 
</IfModule> 
+0

を。ありがとう。 – Imperialized

+0

それは素晴らしい仕事でした、ありがとうございました。 – Imperialized

+0

申し訳ありませんが、編集が完了するまで待っていました。再度、感謝します! – Imperialized

関連する問題