如何重定向多个类似的URL同一个查询? [英] How to redirect multiple similar URLs with one query?
本文介绍了如何重定向多个类似的URL同一个查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在有很多的URL看起来像这样:
I currently have lots of URLs that look like this:
http://www.domain.com/classes-dallas-tx.html
我需要改变所有的URL为以下内容:
I need to change all URLs to the following:
http://www.domain.com/classes-in-dallas- tx.html
我只需要在中的添加到一个没有它现在每一个URL。
I just need to add the "in" into every URL that doesn't have it right now.
有一个查询,我可以使用.htaccess文件,将承担我所有的网址照顾?我打算使用301重定向。
Is there one query I can use for the .htaccess file that will take care of all the URLs for me? I'm planning on using the 301 redirect.
谢谢!
推荐答案
尝试:
RedirectMatch 301 ^/([^-]+)-([^-]+)-([^-]{2})\.html$ /$1-in-$2-$3.html
或
RewriteEngine On
RewriteRule ^/?([^-]+)-([^-]+)-([^-]{2})\.html$ /$1-in-$2-$3.html [L,R=301]
在你的文档根htaccess文件。
in the htaccess file in your document root.
这篇关于如何重定向多个类似的URL同一个查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文