简体   繁体   中英

Apache 2.4 mod_rewrite and RewriteCond %{QUERY_STRING} empty

So far I've been using

RewriteCond %{QUERY_STRING} =""

or

RewriteCond %{QUERY_STRING} !.*=.*

as condition to check is my query string empty before applying rewrite rule. As of Apache 2.4 these directives no longer work.

For example, for my http://test.loc/ address mod_rewrite log output is as follows:

RewriteCond: input='ver=1.0' pattern='=""' => not-matched, referer: http://test.loc/

or when using second directive

RewriteCond: input='ver=1.0' pattern='!.*=.*' => not-matched, referer: http://test.loc/

Any help is appreciated.

使用正则表达式尝试:

RewriteCond %{QUERY_STRING} ^(input=[^&]*)?$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM