URL Rewrite outbound rule examples

Here I’m providing short examples with ui rules only. I’ll assume you have some knowledge in URL Rewrite otherwise I’ll suggest you to read official documentation at http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module

I’m listing below some examples in the form of questions and how to solve them

Outbound rules

Note: in some of the outbound rules precondition responseHtml1 configured as below

1) Add custom script at the end of the response html

2) Add custom script at the beginning of response html

3) Rewrite subdomain with different domain with same URL path and query

Example:  I want to rewrite




Only domain part is changing, path and query is same.

4) Modify redirect location domain to a different domain with same path and query only when particular words exists.

For example:

Modify response header location if path starting with accounts or customer to different domain

http://www.rajbandi.dev/account/login.aspx  or http://www.rajbandi.dev/customer/login.aspx


http://www.rajbandi.com/account/login.aspx or http://www.rajbandi.com/customer/login.aspx

5) Remove body onload function in response html





6) Find all the links with some text and prevent click on them


Click here to visit rajbandi.dev;


Click here to visit rajbandi.dev

Alternatively, you can attach some javascript(preventDefault or something) to href

I’ll update more examples asap.

IIS ARR/URL Rewrite wish list

Its nice to have the following features in the next release of ARR/URL rewrite

1) Ability to include complete list of IIS Server Variables.

2) Ability to define a rule to or not to rewrite request headers based on a condition (either POST value or request header value)

What I noticed is ARR rewrites request headers but with rules we cannot modify certain request headers like HTTP_REFERER etc.

3) Ability to inject C# code for pre and post request, response. The only way possible to do this is to define a HTTP module(only response stream can be modified not request).

4) Ability to define a rule that rewrites request header based on response stream matched value (with regex). Its not possible to modify response header by searching a response stream value.