Htaccess Url重定向正则表达式

时间:2015-08-27 17:15:38

标签: regex apache .htaccess mod-rewrite redirect

传入网址 attorneys/attorney_detail.php?AttorneyID=23&Source=Title&Title=Partner

输出网址/attorney/static-name-here/

我尝试了很多方法来进行重定向,但它没有正确匹配,只是希望ID=##attorneys/attorney_detail.php部分在一起。

这是我到目前为止所拥有的...... 我想删除尾随查询字符串。

RewriteCond %{QUERY_STRING} AttorneyID=23 [NC]
rewriterule ^attorneys/attorney_detail.php http://www.web.com/attorney/name-here/ [R=301,L]

1 个答案:

答案 0 :(得分:0)

您可以使用:

RewriteCond %{QUERY_STRING} (^|&)AttorneyID=23(&|$) [NC]
RewriteRule ^attorneys/attorney_detail\.php$ /attorney/name-here/? [R=301,L,NC]
将删除任何现有查询字符串中的

?

相关问题