5

我知道我可以在 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 可以检查请求正文并将检查结果加载到环境变量中吗?那会工作...

4

1 回答 1

5

您无法使用 mod_rewrite 检查请求正文。

如果您可以这样做,您可能必须将 POST 请求重写为脚本。如果您重定向它们,浏览器并不总是会重新发送 POST 数据。

于 2013-12-03T19:19:56.530 回答