在IIS7 URL重写模块中,我可以在重定向规则中指定不适用于http-post请求吗?

Ble*_*ger 15 iis-7 url-rewriting http-post

在IIS7 URL Rewrite模块中,我可以在重定向规则中指定不适用于http-post请求吗?我使用Microsoft提供的模板来小写所有URL并附加一个尾部斜杠.但是我有一个AJAX帖子请求不符合这个规范,但他们打破我们他们被重写为301s.我并不担心对SEO的POST请求所以我更愿意,如果我可以在规则中指定忽略它.以下是我的规则:

            <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>
Run Code Online (Sandbox Code Playgroud)

pat*_*dge 30

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

<add input="{REQUEST_METHOD}" matchType="Pattern" pattern="POST" ignoreCase="true" negate="true" />
Run Code Online (Sandbox Code Playgroud)

  • 我只发现在IIS中的规则系统中磕磕绊绊.当您键入第一个`{`时,"添加条件"窗口在输入字段上提供智能感知体验. (3认同)
  • 谢谢你的回答.这对我来说是一个很大的帮助,虽然我发现你需要在这种情况下指定negate ="true",以便重写规则适用于不是REQUEST_METHOD = POST的东西. (2认同)