问题描述:

I have a website with 1500 posts that need to be redirected.

I have conflicting categories due to which I am unable to redirect complete category. Current structure is as below:

Cars category

Redirect 301 /blog/videos/top-5-cars http://www.example.net/articles/cars/videos/top-5-cars

Holiday Category

Redirect 301 /blog/videos/exotic-holiday-locations http://www.example.net/articles/holiday/videos/exotic-holiday-locations

Since /blog/videos/ fall under both Cars & Holiday category I am unable to redirect as below

Redirect 301 /blog/videos /articles/holiday/videos

This is the case with 1500 articles. Is it wise to write redirect rule for 1500 articles in .htaccess? Is there a better workaround?

Please suggest.

网友答案:

Replace your Redirect directive with RedirectMatch directive that can match using regex to give you precise matching.

RedirectMatch 301 ^/blog/videos/top-5-cars/?$ /articles/cars/videos/top-5-cars

RedirectMatch 301 ^/blog/videos/exotic-holiday-locations/?$ /articles/holiday/videos/exotic-holiday-locations

RedirectMatch 301 ^/blog/videos/?$ /articles/holiday/videos
相关阅读:
Top