本文介绍了匹配的RewriteCond某些查询参数/值对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须做一个重定向到另一台主机,如果某个参数/值对的查询字符串。

I have to do a redirect to another host if a certain parameter/value pair is in the querystring.

到目前为止,我有

RewriteCond %{REQUEST_URI}?%{QUERY_STRING} [&\?]abc=23&?
RewriteRule ^(.*)$ http://anotherserver.com/$1 [R,NC,L]

这适用于:

/index.php?id=95&abc=23
/index.php?abc=23&id=95
/index.php?id=95&abc=23&bla=123

但它也符合 /index.php?id=95&abc=234 例如。

我需要一个匹配正好花样ABC = 23 ,不管它在哪里发生。

I need a pattern that matches exactly abc=23, no matter where it occurs.

在此有什么建议? : - )

Any suggestions on this? :-)

推荐答案

我会尝试这个正则表达式(安培; | ^)ABC = 23(安培; | $)而对手只有对%{QUERY_STRING}

I'd try this regex (&|^)abc=23(&|$) and match is only against %{QUERY_STRING}.

这篇关于匹配的RewriteCond某些查询参数/值对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 02:36