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
Open Internet Information Services (IIS) Manager > Servername > Sites > example.com > URL rewrite. Select each rewrite rule and disable them by clicking on Disable Rule.
To see if the URL Rewrite module is installed, open IIS Manager and look in the IIS group - if the module is installed, an icon named URL Rewrite will be present.
In IIS Manager, expand the server, expand Sites, and expand Default Web Site. Select the virtual directory, and verify Features View is selected at the bottom of the page. In the IIS section, double-click HTTP Redirect.
I had the same problem with my redirects.
What worked for me was:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With