问题
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