301 redirects and url concatenation

你离开我真会死。 提交于 2019-12-11 09:28:47

问题


I need to do 301 redirects on 100+ urls so was wondering if it's possible to use concatenation on the urls so that i don't have to type in every single one.

Sample urls would be similar to the following:

www.mysite.co.uk/ThisCategory/ThisSubCategory/reviews
www.mysite.co.uk/AnotherCategory/AnotherSubCategory/reviews
www.mysite.co.uk/YetAnotherCategory/YetAnotherSubCategory/reviews

I'm sure there is a way to just take any url beginning with www.mysite.co.uk/ and ending in /reviews but i can't figure it out.


回答1:


Put the following in htaccess at the root level:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.mysite.co.uk$ [NC]
RewriteRule ^(.*)/reviews/?$ http://new-web-page [R,L]


来源:https://stackoverflow.com/questions/25902246/301-redirects-and-url-concatenation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!