在 IIS7 URL Rewrite 模块中,我可以在重定向规则中指定不适用于 http-post 请求吗? [英] In the IIS7 URL Rewrite module, can I specify in a redirect rule to not apply to http-post requests?

查看:23
本文介绍了在 IIS7 URL Rewrite 模块中,我可以在重定向规则中指定不适用于 http-post 请求吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 IIS7 URL Rewrite 模块中,我可以在重定向规则中指定不适用于 http-post 请求吗?我正在使用 Microsoft 提供的模板来小写所有 url 并附加一个斜杠.但是,我有一个不符合此规范的 AJAX 发布请求,但它们破坏了我们,它们被重写为 301.我不担心 SEO 的 POST 请求,所以我希望我可以在规则中指定忽略它.以下是我的规则:

In IIS7 URL Rewrite module, can I specify in a redirect rule to not apply to http-post requests? I am using the templates provided by Microsoft to lowercase all urls and to append a trailing slash. However I have a AJAX post requests that don't meet this specification but they break we they are rewritten as 301s. I am not worried about POST requests for SEO so I would prefer if I could just specify in the rule to ignore it. Below are my rules:

            <rule name="AddTrailingSlashRule" stopProcessing="true">
                <match url="(.*[^/])$" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                </conditions>
                <action type="Redirect" url="{R:1}/" />
            </rule>
            <rule name="LowerCaseRule" stopProcessing="true">
                <match url="[A-Z]" ignoreCase="false" />
                <action type="Redirect" url="{ToLower:{URL}}" />
            </rule>

推荐答案

您可以在条件下访问 {REQUEST_METHOD} 变量中的那个.

You have access to that in the {REQUEST_METHOD} variable under the conditions.

<add input="{REQUEST_METHOD}" matchType="Pattern" pattern="POST" ignoreCase="true" negate="true" />

这篇关于在 IIS7 URL Rewrite 模块中,我可以在重定向规则中指定不适用于 http-post 请求吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆