如何将多个类似的网址重定向一个查询?(How to redirect multiple simila

2019-10-30 17:57发布

我现在有很多的URL看起来像这样:

http://www.domain.com/classes-dallas-tx.html

我需要改变所有的URL为以下内容:

http://www.domain.com/classes-in-dallas-tx.html

我只需要添加“在”成没有它现在每一个URL。

是否有一个查询,我可以使用.htaccess文件,将采取对我所有的URL的照顾? 我打算使用301重定向。

谢谢!

Answer 1:

尝试:

RedirectMatch 301 ^/([^-]+)-([^-]+)-([^-]{2})\.html$ /$1-in-$2-$3.html

要么

RewriteEngine On
RewriteRule ^/?([^-]+)-([^-]+)-([^-]{2})\.html$ /$1-in-$2-$3.html [L,R=301]

在您的文档根htaccess文件。



文章来源: How to redirect multiple similar URLs with one query?