我知道我可以在rewritecond中检查GET查询字符串参数,如下所示:
RewriteCond %{REQUEST_URI} ^/somepath/somepath RewriteCond %{REQUEST_METHOD} GET RewriteCond %{QUERY_STRING} try=3 RewriteCond %{QUERY_STRING} name=([^&]*) RewriteRule ^/somepath/somepath(.*) /otherpath/otherpath?name=%1 [R]
如何检查请求正文中的POST参数?我听说mod_security可以做到,但我没有找到任何关于如何将mod_security与mod_rewrite一起使用的例子,如上例所示.
我打算用这样的东西来处理POST:
RewriteCond %{REQUEST_URI} ^/somepath/somepath RewriteCond %{REQUEST_METHOD} POST RewriteRule ^/somepath/somepath(.*) /otherpath/otherpath [PT]
...除了我需要一个RewriteCond来检查POST参数以查看"try = 3".
modsecurity可以检查请求体并将检查结果加载到环境变量中吗?那会有用......
您无法使用mod_rewrite检查请求正文.
如果您可以执行此操作,则可能必须将POST请求重写为脚本.如果重定向它们,浏览器并不总是会重新发送POST数据.