IIS URL Rewrite 2.0 – Release to Web
The IIS URL Rewrite Module 2.0 – RTW is available for download. IIS URL Rewrite v2.0 is an incremental release that includes all the features from version 1.1, and adds extensibility support and outbound response rewriting. More specifically, v2.0 can be used to:
- Express complex URL rewriting logic by using custom rewrite providers written in .NET.
- Replace the URLs generated by a web application in the response HTML with a more user friendly and search engine friendly equivalent
- Fix up the content of any HTTP response by using regular expression pattern matching.
- Modify HTTP request and response headers and IIS server variables.
For the complete list of features available in this version, refer to Using URL Rewrite Module 2.0.
Install the URL Rewrite 2.0 – RTW
To install the URL Rewrite 2.0, use the download links at the module’s home page at http://www.iis.net/expand/urlrewrite. Note that this is a final, production ready release that is officially supported by Microsoft.
Upgrade notes:
- If a previous version of URL Rewrite Module, such as v1.0 and v1.1, is already installed then it will be upgraded to the v2.0;
- If an RC version of the URL Rewrite Module 2.0 is already installed, then it will be upgraded to RTW version.
Install the URL Rewrite Extensibility Samples
An important new feature in this release is the support for custom rewrite providers that can be written in .NET. Custom rewrite providers can be used to implement complex rewrite logic which cannot be expressed by using built-in rewriting functionality.
The URL Rewrite Extensibility Samples include the .NET assemblies and the source code implementing the following providers:
- DbProvider – this provider can be used to retrieve rewrite mappings from a SQL Server database table by executing a stored procedure;
- FileMapProvider – this provider can be used to retrieve rewrite mappings stored in a text file;
- FileContainsProvider – this provider can be used to check if any string in a text file is a substring of the provider’s input string.
Download the URL Rewrite Extensibility Samples from MSDN Code Gallery.
More Information
The following documentation about URL Rewrite 2.0 is available on IIS.net:
- Using Custom Rewrite Providers with URL Rewrite Module
- Developing a Custom Rewrite Provider for URL Rewrite Module
- Creating Outbound Rules for URL Rewrite Module
- Reverse Proxy with URL Rewrite 2.0 and Application Request Routing
- Using Outbound Rules to insert Web Analytics Tracking Code
- Setting HTTP Request Headers and Server Variables
- Modifying HTTP Response Headers
- SEO Rule Templates
- User Friendly URL – rule template
- Reverse Proxy – Rule Template
- URL Rewrite Module v2.0 configuration reference
Also, visit the URL Rewrite Forum on IIS.NET if you have run into any problems when using the module or have questions or suggestions.
2,416 views
ruslany on March 11th 2010 in URLRewrite

(5 votes, average: 4.20 out of 5)
This is great news that we have RTW!
Hi Ruslan – Not sure if this is a bug:
I am using URL Rewrite 2.0 for HTTPS redirect using the following rule:
The backreference {R:1} does not seem to be working. The URL I am testing is:
http://www.server.com/XYZR2
and I get the following redirect:
https://www.server.com/
I have ended up using https://{HTTP_HOST}/{HTTP_URL} as a workaround.
Also in the previous versions documentation there was a section about the impact of server variables usage and output caching. {HTTPS} server variable was one of the variables that was not on the white list back then. Is that still the case? If yes how can I prevent the use of this variable and achieve a SSL redirect without compromising the output caching I have setup?
Thanks!
@humairm: Could you XML encode the rewrite rule before posting it? Otherwise WordPress filters out XML markup.
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
Ruslan – One other issue I have noticed is if I have a nested web application in IIS (XYZR2 is the parent and XYZR2/py is the nested) the nested application does not work with URL Rewrite (the parent application works fine). When I go to the URL Rewrite settings for the nested application I get an error message:
Cannot add duplicate collection entry of type ‘rule’ with unique key attribute ‘name’ set to ‘Redirect to HTTPS’
Although in the web.config there is only one entry for the element
@himairm: I think that the reason you see this behavior with back-reference is that most probably you have the rewrite rule defined in web.config file located in the directory XYZR2 and this causes the module to give a relative path to the rewrite rule (i.e. with XYZR2 stripped off from the URL). Because of that the (.*) matches an empty string and hence the back-reference is empty. The rule will work if you put it in the web.config at the root folder of the website. The workaround that you have will also work, but I think you need to use {URL}, not {HTTP_URL}.
Regarding the {HTTPS} variable – if you use it for the redirect rule then it should not matter. The output cache disabling logic is only applicable when using rewrite, not redirect.
Regarding the error about unique key – Why do you need the same rule on two different levels? You can just create one “Redirect to HTTPs” rule in the root directory of the web site and it will take care of all the subdirectories and applications. The error is because you have a rule with the same name defined on two different configuration levels, which is not allowed.
Hi Ruslan – Right on all counts; the URL Rewrite icon in IIS Management Console appearing for each subfolder was a bit confusing and I got started on the wrong track. I moved the web.config to the Root and all is working as expected. Thanks much for your response!
If I am content with 1.1 features, is there a reason to upgrade to 2.0? Are there known bug fixes that would impact performance?
@svk: If you do not need any of the new features, then there is no need for you to upgrade from 1.1.
i want to simulate my clients environment, application is served as HTTP but client demands HTTPS through middleman appliance that stablishes vpn/ssl connections, appliance rewrites all URLs and exposes the application to internet.
example…
http://lanServer/path/login.aspx
appliance url rewrite…
https://internetServer/path/login.aspx
i want to debug some problems related to javascript, when accessing application from internet, is it possible to use iis7 url rewrite module to debug locally?
Hello,
I am using URL rewrite 2.0 to handle HTTPS redirects. I have the following code in my web.config setup through IIS and the website doesn’t get redirected or even throw a site required SSL error. It just loads like it normally would. I have made sure all SSL requirements have been made. Please help and let me know what I am doing wrong.
Sorry, the code didn’t show. Here is my code that I am using.
rewrite
rules
rule name=”Redirect to Https” stopProcessing=”true”
match url=”(.*)”
conditions
add input=”{HTTPS}” pattern=”^OFF$”
conditions
action type=”Redirect” url=”https://{HTTP_HOST}/{URL}” redirectType=”SeeOther”
rule
rules
rewrite
Hi MyBestGuess. The rule looks correct. I would suggest to enable Failed Request Tracing and check if the rule gets executed at all.