htaccess partial filename suffix match

2019-08-26 08:35发布

As part of a site migration, I have a bunch of old files that I want to redirect to a new site.

The old files all end with _reviews.html, but the new destination is on a different server, without the "_reviews" part of the name, but still ending in .html.

For example:

Old:

www.a.com/my_product1_reviews.html 

New:

www.b.com/my_product1.html

I have a few hundred like this so I didn't really want to do them one at a time, but I can't seem to get the correct syntax.

标签: .htaccess
1条回答
beautiful°
2楼-- · 2019-08-26 09:08

Try this:

RewriteEngine On
RewriteBase /
RewriteRule (.*)_reviews.html$ http://www.b.com/$1.html [L,R=301]
查看更多
登录 后发表回答