Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the IIS7 URL Rewrite module, can I specify in a redirect rule to not apply to http-post requests?

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>
like image 458
Blegger Avatar asked May 13 '11 15:05

Blegger


People also ask

What is the difference between URL Rewrite and redirect?

Simply put, a redirect is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. A rewrite is a server-side rewrite of the URL before it's fully processed by IIS.

What is a URL Rewrite rule?

A rewrite rule defines the logic of what to compare or match the request URL with, and what to do if the comparison is successful. Rewrite rules consists of the following parts: Pattern – The rule pattern is used to specify either the regular expression or a wildcard pattern that is used to match URL strings.

What is Request_uri in URL Rewrite?

Returns exact URL what you requested. For example, if you have default.aspx file in the root and you will access your website root.


1 Answers

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" />
like image 52
patridge Avatar answered Oct 12 '22 10:10

patridge