2016-09-01 15 views
1

私はus.example.com、gb.example.com、fr.example.com、pl.example.comなど301リダイレクト

のように私のメインのexample.com内の多くのサブドメインを持っています今は、存在しないサイトから新しいサイトに301のリダイレクトを行う必要があります。

Redirect 301 /system_example/systems/system_abc.html http://pl.example.com/system_example/systems/all_systems.html 

しかし、そのパス/system_example/systems/system_abc.htmlを持っている他のすべてのサブドメインが今http://pl.example.com/system_example/systems/all_systems.html

にリダイレクトされるように、これは私が持っているウェブサイトの構造では不可能である。通常、私はそれをできるだけ簡単な方法を行っているでしょう

リダイレクトはpl.example.comサブドメイン内でのみ行いたいだけです。他のすべてのリダイレクトはそのままにしておく必要があります。このタイプのリダイレクトのみが機能していても、そうでない場合:

Redirect 301 http://pl.example.com/system_example/systems/system_abc.html http://pl.example.com/system_example/systems/all_systems.html 

.htaccess経由ですべてのことを達成できますか?

+0

このパターンはすべてのサブドメインに適用するか、単に「pl.example.com」に適用する必要がありますか? – hjpotter92

+0

現在のところ、1つのサブドメインのみです。リダイレクト301 http://pl.example.com/system_example/systems/system_abc.html http://pl.example.com/system_example/systems/all_systems.html – Marcin

答えて

0

あなたはmod-rewriteはその後、有効にしている場合:

RewriteEngine On 

RewriteCond %{HTTP_HOST} ^pl\.example\.com$ [NC] 
RewriteRule ^/?(system_example/systems)/system_abc\.html$ /$1/all_systems.html [R=301,L] 

をそれ以外の場合は、唯一のmod-aliasを使用して:

<If "%{HTTP_HOST}" == "pl.example.com"> 
    RedirectPermanent /system_example/systems/system_abc.html /system_example/systems/all_systems.html 
</If> 

を私は二番目の構文的に正しいかどうかを確認していません。

+0

私は何を間違って記述しましたか? ?それは働いていない:/ でRewriteBase/ するRewriteCondの%{HTTP_HOST}^pl.example.com $ [NC] のRewriteRule^/(system_example /システム)/system_example_pp.html$/$ 1 /優位性に RewriteEngine ?を。 html [R = 301、L] – Marcin

+0

@Marcinは、mod-rewriteがアクティブであるかどうかをチェックします。 Linuxシステムでは、 'sudo a2enmod rewrite'を実行します – hjpotter92