apache - 如何使用带有 POST 参数的 Apache mod_rewrite rewritecond?

标签 apache mod-rewrite mod-security

我知道我可以在 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 数据。

关于apache - 如何使用带有 POST 参数的 Apache mod_rewrite rewritecond?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20359719/

相关文章:

.htaccess - 允许使用 htaccess 访问一个目录吗?

apache - 谷歌标签管理器包含在 Apache 中传递 mod-security 规则

linux - Apache 中的自定义响应

java - Tomcat org.apache.catalina.LifecycleException\无法运行服务器\http 404错误

php - .htaccess RewriteCond,其中 URI 不包含域

.htaccess - 当一个子域都指向完全相同的文件时,如何将它们重定向到另一个子域?

php - 如何检查 mod_security 是否被 PHP 激活(无 curl)

nginx - "SecCollectionTimeout is not yet supported"在 WAF owasp modsecurity crs 与 NGINX

apache - HTACCESS 导致错误 404

apache - mod_rewrite 给我 404