问题描述:

I have the follow rewrite rule defined in IIS that I would like to maintain. The problem I am encountering is that when the application behind this rewrite returns an HTTP redirect response (303 or 307) to a host other than itself, the URL rewrite module is changing the host on the Location header of the response. (I have confirmed that the URL Rewrite is at fault since this behavior is not observed when accessing the site directly). IIS is doing this even though I do not have any outbound rules defined. How do I keep IIS rewriting the incoming requests, but prevent it from doing this unconfigured and unintended processing of the outgoing responses?

<rule name="ServiceName Rewrite">

<match url="^(ServiceName/)?(.*)" />

<conditions>

<add input="{HTTP_HOST}" pattern="^ServiceName([.]company[.]com)?$" />

</conditions>

<action type="Rewrite" url="http://generic.company.com/ServiceName/{R:2}" />

</rule>

Edit:

To clarify, my web application is returning a response of

HTTP 307

Location: http://somesite.company.com/path/to/item

and IIS is unhelpfully changing this to

HTTP 307

Location: http://ServiceName.company.com/path/to/item

网友答案:

I had the same problem with my redirects.

What worked for me was:

  1. In IIS Manager go to your server
  2. Enter Application Request Routing Cache
  3. In Actions go to Server Proxy Settings
  4. Disable checkbox "Reverse rewrite host in response headers"
  5. Restart your server
相关阅读:
Top