[英]Redirect all deeplinks to new domain with slight change in all URL's
I am trying to redirect all pages of DomainA to DomainB but with a slight change in the URL structure. 我试图将DomainA的所有页面重定向到DomainB,但是URL结构稍有变化。
For example: 例如:
I need to redirect: 我需要重定向:
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
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
I can manage to redirtect allurls to new domain like this: 我可以设法将所有网址重新定向到新域,如下所示:
RewriteEngine on RewriteRule ^cars/(.*)$ http://www.domainb.com/vehicles/ $1 [R=301,L]
RewriteRule上的RewriteEngine ^ cars /(.*)$ http://www.domainb.com/vehicles/ $ 1 [R = 301,L]
But I cant work out how to change the last word. 但我无法解决如何更改最后一个字。 theres thousands of these urls so i cant manually do a list of 301s.
这些网址有成千上万个,所以我不能手动执行301清单。 I basically need to redirect all urls to new domain but switch
/cars/
to /vehicles/
and -motors
to -cars
. 我基本上需要将所有url重定向到新域,但将
/cars/
切换到/vehicles/
并将-motors
到-cars
。
Any help appreciated. 任何帮助表示赞赏。
thanks 谢谢
You can use this in your .htaccess
file : 您可以在
.htaccess
文件中使用它:
RewriteEngine On
RewriteRule ^cars/(.*)-motors/? http://www.domainb.com/vehicles/$1-cars [R=302,L]
Change [R=302]
for [R=301]
when test work well. 测试工作正常时,将
[R=301]
[R=302]
更改为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.