mod_rewrite只在GET上

Cod*_*ian 9 apache mod-rewrite post

这是一个远景,但我希望找到一个简单的解决方法,以解决一个奇怪的错误,只有在应用程序省略/推断查询字符串时才会显示.

在深入研究千行第三方javascript之前,我想知道是否可以使用mod_rewrite自动应用查询字符串.

RewriteRule    ^index\.php$  index.php?module=Home&action=index
Run Code Online (Sandbox Code Playgroud)

现在,这可以正常工作,除非有时所有数据都将被POST,所以我需要一个,RewriteCond所以规则只会触发GET请求,而不是POST请求.

这可能吗?

Sim*_*ote 15

我建议明确并且只在请求方法是GET时触发RewriteRule,而不是在没有POST的时候,因为还有很多其他方法.所以你的重写条件可能如下所示:

RewriteCond %{REQUEST_METHOD}  =GET

RewriteRule    ^index\.php$  index.php?module=Home&action=index
Run Code Online (Sandbox Code Playgroud)


ale*_*lex 13

添加此条件...

RewriteCond %{REQUEST_METHOD} !POST
Run Code Online (Sandbox Code Playgroud)

...不匹配POST请求.