Apache 2.4 mod_rewrite and RewriteCond %{QUERY_STRING} empty


Apache 2.4 mod_rewrite and RewriteCond %{QUERY_STRING} empty

到目前为止我一直在使用

RewriteCond %{QUERY_STRING} =""

RewriteCond %{QUERY_STRING} !.*=.*

作为条件,在应用重写规则之前检查我的查询字符串是否为空。从Apache 2.4开始,这些指令不再有效。

例如,对于我的 http://test.loc/地址mod_rewrite日志输出如下:

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

或使用第二指令时

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

任何帮助,不胜感激。

用正则表达式试试这个:

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