307 redirect rule with Microsoft Rewrite Module 2.

2019-08-05 18:35发布

问题:

Is it possible to make a 307 redirect rule in web.config with Microsoft Rewrite Module 2.0 for IIS 7? The goal is to redirect some post form requests to another path within the same domain.

回答1:

Set redirectType attribute of action tag to "Temporary"

Eg.

<rewrite>
      <rules>
        <rule name="RedirectRule" stopProcessing="true">
          <match url="(.*)" ignoreCase="true" />
          <action type="Redirect" url="http://www.newdomain.com/{R:1}" redirectType="Temporary" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="www\.old-domain\.com" />
            </conditions>
        </rule>
      </rules>
    </rewrite>