0
我需要一种方法来重定向所有和只有从文件夹开始的网址:“home /”和“car /”,从example.com到jp.example.com。如何仅在这些情况下重写?
因此,例如:
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的所有URL来jp.example.com
这是行不通的