Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent IIS Url Rewrite module from modifying HTTP 303/307 responses

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
like image 993
erdomke Avatar asked Sep 29 '16 16:09

erdomke


People also ask

How do I disable URL Rewrite in IIS?

Open Internet Information Services (IIS) Manager > Servername > Sites > example.com > URL rewrite. Select each rewrite rule and disable them by clicking on Disable Rule.

How do you check if URL Rewrite is enabled IIS?

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.

How do I redirect the default website in IIS to virtual directory?

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.


1 Answers

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
like image 173
Mateusz Avatar answered Oct 02 '22 01:10

Mateusz