![](/img/trans.png)
[英]htaccess Redirect - Old Domain to New Domain with Slight Change in link structure
[英]Redirect all deeplinks to new domain with slight change in all URL's
我試圖將DomainA的所有頁面重定向到DomainB,但是URL結構稍有變化。
例如:
我需要重定向:
http://www.domaina.com/cars/fast-motors- > http://www.domainb.com/vehicles/fast-cars http://www.domaina.com/cars/slow-motors- > http ://www.domainb.com/vehicles/slow-cars http://www.domaina.com/cars/red-motors- > http://www.domainb.com/vehicles/red-cars http:// www.domaina.com/cars/pink-motors- > http://www.domainb.com/vehicles/pink-cars
我可以設法將所有網址重新定向到新域,如下所示:
RewriteRule上的RewriteEngine ^ cars /(.*)$ http://www.domainb.com/vehicles/ $ 1 [R = 301,L]
但我無法解決如何更改最后一個字。 這些網址有成千上萬個,所以我不能手動執行301清單。 我基本上需要將所有url重定向到新域,但將/cars/
切換到/vehicles/
並將-motors
到-cars
。
任何幫助表示贊賞。
謝謝
您可以在.htaccess
文件中使用它:
RewriteEngine On
RewriteRule ^cars/(.*)-motors/? http://www.domainb.com/vehicles/$1-cars [R=302,L]
測試工作正常時,將[R=301]
[R=302]
更改為。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.