当前位置: 动力学知识库 > 问答 > 编程问答 >

apache - Thousands .htaccess redirect 301

问题描述:

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
分享给朋友:
您可能感兴趣的文章:
随机阅读: