0

example.com から jp.example.com に、フォルダー"home/"および"car/"で始まるすべての URL のみをリダイレクトする方法が必要です。

たとえば、次のようになります。

example.com/home/test.html ---> jp.example.com/home/test.html
example.com/car/test.html ---> jp.example.com/car/test.html
jp.example.com/home/second-test.html ---> jp.example.com/home/second-test.html
jp.example.com/third-test.html ---> example.com/third-test.html 

私はこのコードを使用しています:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^jp.example.com$
RewriteRule ^(.*)$ http://jp.example.com/$1 [R=301]

しかし、example.com から jp.example.com にすべての URL を書き換えるので、機能しません。

4

2 に答える 2

0

/home次のように、リクエストされた URI がまたはで始まるかどうかを確認する必要があります/car

RewriteEngine on
RewriteCond %{HTTP_HOST} !^jp.example.com$ [NC]
RewriteCond %{REQUEST_URI} ^(/home|/car)(/.*)?$ [NC]
RewriteRule ^(.*)$ http://jp.example.com/$1 [R=301]
于 2013-11-02T18:43:47.313 に答える