Using the URL Rewrite Module (2023)

  • Article
  • 7 minutes to read

by Ruslan Yakushev

About the URL Rewrite module

The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create powerful customized rules to map request URLs to friendly URLs that are easier for users to remember and easier for search engines to find. You can use the URL Rewrite module to perform URL manipulation tasks, some of which include:

(Video) URL Rewrite in IIS

  • Define powerful rules to transform complex URLs into simple and consistent Web addresses.
  • Easily replace Web application URLs to produce user and search engine friendly results.
  • Rewrite URLs based on HTTP headers and IIS server variables.
  • Perform redirects, send custom responses, or stop HTTP requests based on the logic expressed in the rewrite rules.
  • Control access to Web site content based on URL segments or request metadata.

The URL Rewrite module is available both as a download that you can install on your own IIS server, and on Microsoft's Azure Web Sites cloud platform.

URL Rewrite 2.0 features

The Microsoft URL Rewrite module 2.0 includes the following key features:

  • Rules-based URL rewriting engine. Rewrite rules define the logic used to analyze request URLs and map them to rewite URLs when the request URL matches a defined rule. Web server and site administrators can use rewrite rule sets to define URL rewriting logic.
  • Regular expression pattern matching. Rewrite rules can use regular expression syntax for pattern matching as defined in ECMA-262.
  • Wildcard pattern matching. Rewrite rules can use wildcard syntax for pattern matching.
  • Global and distributed rewrite rules. URL Rewrite uses global rules to define server-wide URL rewriting logic. These rules are defined within the applicationHost.config file, and they supercede rules configured at lower levels in the configuration hierarchy. The module also uses distributed rules to define URL rewrite logic specific to a particular configuration scope. This type of rule can be defined on any configuration level by using Web.config files.
  • Access to server variables and HTTP headers. Server variables and HTTP headers provide additional information about current HTTP requests. This information can be used to configure rewrite rules or to compose the output URL.
  • Various rule actions. Instead of rewriting a URL, a rule may perform other actions, such as issue an HTTP redirect, abort the request, or send a custom status code to HTTP clients.
  • Support for IIS kernel mode and user mode output caching. IIS output caching provides significant performance improvements for Web applications. The URL Rewrite module is fully compatible with both types of output caching. This means that it is possible to safely cache responses for rewritten URL's and thus boost the performance of Web applications that rely on URL rewriting.
  • String manipulation functions. Built-in string manipulation functions can be used to convert URLs to lowercase and to perform URL encoding and decoding.
  • Rewrite maps. A rewrite map is an arbitrary collection of name-value pairs. You can use a rewrite map within rewrite rules to generate the substitution URL. Rewrite maps are particularly useful when you have a large set of rewrite rules, all of which use static strings (i.e. there is no pattern matching used). In those cases, instead of defining a large set of simple rewrite rules, you can put all the mappings between into the rewrite map using the input URL as a key, and the substitution URL as value. You can then have one rewrite rule that references the rewrite map to look up substitution URL based on the input URL.
  • Failed Request Tracing support. IIS Failed Request Tracing can be used to troubleshoot errors related to URL rewriting.
  • Rule templates. A rule template is an extension for the URL Rewrite module user interface that simplifies creation of rewrite rules for a particular task. The module includes 3 rule templates, and also supports plugging in any number of custom templates.
  • User Interface (UI) for testing regular expression and wildcard patterns. A UI for testing rule patterns is provided with the module. Using the UI, you can quickly check the results of a regular expression or wildcard pattern in a rewrite rule. You can also use the UI for troubleshooting and debugging problems related to pattern matching.
  • UI for managing rewrite rules and rewrite maps. Rewrite rules and rewrite maps can be added, removed, and edited by using the URL Rewrite Module from the IIS Manager.
  • UI for importing mod_rewrite rules. The URL Rewrite module includes a UI for converting rewrite rules from mod_rewrite format into an IIS format.

Where to get the URL Rewrite module

For more information and to download the module, see the URL Rewrite extension home page.

Upgrading from Go Live release

If you already have the Go Live release of URL rewrite module installed the installation package will upgrade it to URL Rewrite version 2.0. All rewrite rules in your ApplicationHost.config and Web.config files will be preserved.

(Video) URL Rewrite Module in IIS 10 on Windows Server 2016

ASP.NET update

The URL Rewrite module installer package includes an ASP.NET update that fixes ASP.NET bugs specific to the URL Rewrite module. Specifically, the update contains fixes for the following bugs:

  1. ~ operator in ASP.NET Web server control is resolved incorrectly when using URL Rewrite.
  2. ASP.NET SiteMap.CurrentNode property returns null when sitemap contains virtual URLs.

The update is applied only if the machine where URL Rewrite module is being installed has .NET Framework version 3.5 SP1 or higher. If you install the required version of the .NET Framework after you install the URL Rewrite module, you can apply the ASP.NET update by running the URL Rewrite module installer and then selecting the Repair option in the installer dialog.

For more details about these and other ASP.NET issues related to URL rewriting, see URL Rewriting for ASP.NET Web Forms.

Using the module

These articles cover the functionality of the URL Rewrite Module and explain how to use it to implement common URL rewriting scenarios.

(Video) Install URL rewrite module in Windows 2022 for IIS

Learning the basics

  • Creating Rewrite rules

  • Using Failed Request Tracing to trace rewrite rules

  • Using global and distributed rules

  • Using Rewrite maps

    (Video) An Intro to URL Rewrite + adding www to domain name

  • Importing Apache mod_rewrite rules

  • Enabling Pretty Permalinks in WordPress

  • Rule templates

    • User Friendly URL
    • Rule with Rewrite Map
    • Request Blocking
  • Testing rule and condition patterns

    (Video) IIS 8 - Install URL Rewrite module

References and guidance

  • URL Rewrite Module Configuration reference
  • URL Rewrite and ASP.NET routing
  • URL Rewrite and Request Filtering
  • URL Rewrite for ASP.NET Web Forms
  • Developing rule templates for the URL Rewrite module

Video walkthrough

  • Using the URL rewrite module - video walkthrough

Changes since Go Live release

The following additions, changes, and important bug fixes have been made to URL rewrite module since the Go Live release:

  1. Added string manipulation functions UrlEncode and UrlDecode.
  2. Provided access to a raw original URL via server variable UNENCODED_URL. This server variable now contains the raw encoded URL exactly as it was requested by Web browser.
  3. Added UI for configuring rewrite rules for Application Request Routing (ARR).
  4. Added support for in-place upgrade from the Go Live release of the URL rewrite module.
  5. Added functionality to clean up the internal cache to avoid excessive usage of memory when caching rewrite rules.
  6. Fixed a bug related to rewriting of URLs that contain non-ASCII characters.
  7. Fixed a bug in processing regular expressions that caused character ranges to be evaluated incorrectly for case-insensitive patterns.
  8. Included an update for IIS FastCGI module into the installer package.
  9. Included an update for System.Web.dll into the installer package.
  10. Included an update for the IIS SetUri function into the installer package.

Known Issues

  1. mod_rewrite rules that use REQUEST_URI server variables may not work correctly when imported by using URL Rewrite the Import Rules feature. To fix the imported rules use, you can use any text editor to open the Web.config file that contains those rules. Locate the <rewrite> section, and then within that section replace all instances of the string "{SCRIPT_NAME}" with the string "{URL}".
  2. Digest authentication cannot be used with URL Rewrite module.
  3. ASP.NET Forms authentication uses rewritten URL for redirection. For example, if the requested URL is "/article.htm" and the URL Rewrite module rewrites the URL to "/article.aspx", which is protected by Forms authentication, then ASP.NET will redirect to "/login.aspx?ReturnUrl=%2Farticle.aspx".
  4. Auto-detect mode in ASP.NET Forms authentication uses a rewritten URL for redirection. For example, if the requested URL is "/article.htm" and the URL Rewrite module rewrites the URL to "/article.aspx", which is protected by Forms authentication, then ASP.NET will redirect to "/article.aspx?AspxAutoDetectCookieSupport=1".
  5. UseUri mode in ASP.NET Forms authentication uses rewritten URL for redirection. For example, if the requested URL is "/article.htm" and URL Rewrite module rewrites the URL to "/article.aspx", which is protected by Forms authentication, then ASP.NET will redirect to "/(S(vy2ebt45imfkmjjwboow3l55))/article.aspx".
  6. ASP.NET rewrites back to the original URL when using URI-based authentication or cookie-less session state. For example, when a request is made to "/(S(vy2ebt45imfkmjjwboow3l55))/article.htm" and URL rewrite module rewrites "/article.htm" to "/article.aspx", then ASP.NET will rewrite the URL back to "/article.htm", which may result in a "404 - File Not Found" error.
  7. The IIS DefaultDocument module may redirect to a rewritten URL when the URL Rewrite module rewrites to a folder. For example, if the substitution URL in a rewrite rule is "/folder1/folder2" and these folders exist on the file system and have a Default document configured, then the DefaultDocument module will redirect Web clients to "/folder1/folder2/", thus exposing the rewritten URL. To prevent this from happening, use "/" at the end of the substitution URL when rewriting to a folder, for example, "/folder1/folder2/"


How to install URL Rewrite module in IIS 10? ›

Tutorial IIS - Installing the URL Rewrite module
  1. Access the URL REWRITE website and download the installation package.
  2. Perform the URL REWRITE installation.
  3. Start the application named: IIS Manager.
  4. On the IIS Manager application, select your website. ...
  5. On the top right part of the screen, click on the Add Rule option.
Oct 27, 2020

How do I know if URL Rewrite module is installed? ›

Checking if the URL Rewrite module is installed

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 does URL Rewrite work? ›

The concept of URL rewriting is simple. When a client sends a request to the Web server for a particular URL, the URL rewriting module analyzes the requested URL and changes it to a different URL on the same server.

What is URL rewriting with example? ›

Url rewriting is a process of appending or modifying any url structure while loading a page. The request made by client is always a new request and the server can not identify whether the current request is send by a new client or the previous same client.

How to install URL Rewrite in IIS? ›

To install URL Rewrite, open WebPI, filter for URL Rewrite, and download. Because WebPI isn't installed by default, you may not have it on your system yet. It's still easy to obtain URL Rewrite. Visit in your web browser and search for URL Rewrite.

What is the use of URL Rewrite in IIS? ›

The Microsoft URL Rewrite Module 2.0 for IIS 7 and above enables IIS administrators to create powerful customized rules to map request URLs to friendly URLs that are easier for users to remember and easier for search engines to find.

How to use URL Rewrite to redirect HTTP to HTTPS? ›

  1. Download and install the IIS URL Rewrite module, then launch IIS Manager.
  2. Select the website you want to apply redirection to, then double-click URL Rewrite.
  3. Click Add Rule(s)…
  4. Select Blank rule in the Inbound rules section, then click the OK button.
  5. Give your redirect an easy-to-remember name.

How do I manually install a PowerShell module? ›

Installing PowerShell modules from a NuGet package
  1. Unblock the Internet-downloaded NuGet package ( . ...
  2. Extract the contents of the NuGet package to a local folder.
  3. Delete the NuGet-specific elements from the folder.
  4. Rename the folder. ...
  5. Copy the folder to one of the folders in the $env:PSModulePath value .
Nov 17, 2022

How do I redirect a website to another URL in IIS? ›

Select the site in IIS manager that you want to set the redirect for. Check the box next to Redirect requests to this destination, and fill in the destination page and set the dropdown menu to 302, and click Apply. Now if we navigate to your original page, you should be redirected to the new page.

How do I install a module in PowerShell? ›

The PowerShell system is already available within the Windows operating system and you probably already have many modules available. At the PowerShell prompt, type Get-Module -ListAvailable to see which modules are active. To install a module, use the Get-InstalledModule cmdlet.

How do I enable rewrite modules? ›

Here are the steps enable mod_rewrite in XAMPP, WAMP.
  1. Open httpd. conf. Open the Apache configuration file httpd. ...
  2. Enable mod_rewrite. Look for the following line #LoadModule rewrite_module modules/ Uncomment it by removing # at its beginning. ...
  3. Restart XAMPP,WAMP. Restart XAMPP/WAMP server to apply changes.
Nov 24, 2020

How do I check if a rewrite module is enabled? ›

Open any web browser browser and type following the URL, 'localhost/check. php'. It will display the PHP version details and Apache Configuration. In Apache Configuration, search for the Loaded Modules section, and there you will find all the modules that are enabled.

What is the disadvantage of URL rewriting? ›

Disadvantage of URL Rewriting

It will work only with links. It can send Only textual information.

What are the benefits of URL rewriting? ›

Url-rewriting enables you to transparently forward requests to the new page location without breaking browsers. 2) Improving the search relevancy of pages on your site with search engines like Google, Yahoo and Live.

What is the difference between URL Rewrite and URL routing? ›

URL rewriting is focused on mapping one URL (new url) to another URL (old url) while routing is focused on mapping a URL to a resource. Actually, URL rewriting rewrites your old url to new one while routing never rewrite your old url to new one but it map to the original route.

What is the difference between routing and URL Rewrite? ›

Differences between URL rewriting and ASP.NET routing: URL rewriting is used to manipulate URL paths before the request is handled by the Web server. The URL-rewriting module does not know anything about what handler will eventually process the rewritten URL.

What are the 3 types of URL? ›

type: It specifies the type of the server in which the file is located. address: It specifies the address or location of the internet server. path: It specifies the location of the file on the internet server.

What is a good example of a URL? ›

A typical URL could have the form , which indicates a protocol ( http ), a hostname ( ), and a file name ( index.html ).

What is URL rewriting Tool? ›

URL Rewrite permits Web administrators to easily replace the URLs generated by a Web application in the response HTML with a more user friendly and search engine friendly equivalent. Links can be modified in the HTML markup generated by a Web application behind a reverse proxy.

How do you add a URL to text expander? ›

Place the cursor where you would like the link to appear. Click the Make Link button at the top of the snippet editor and then enter the URL for the website. Click OK.

How do you add a URL? ›

Create a hyperlink to a location on the web

You can also right-click the text or picture and click Link on the shortcut menu. In the Insert Hyperlink box, type or paste your link in the Address box. Note: If you don't see the Address box, make sure Existing File or Web Page is selected under Link to.

How do you rewrite a URL in AEM? ›

One approach is to use a rewrite module in your web server (i.e. mod_rewrite). This will rewrite all incoming URLs to a path that can be resolved to a resource in AEM, before handing it over to the Dispatcher. This is fairly easy to do by using VirtualHost and rewriting the links accordingly depending on the domain.

How do I make a URL link in a text message? ›

There's just one easy step to follow. To include a link in any text message, just type or paste the full URL into your text. Most messaging platforms will automatically turn the URL into a link that allows contacts to click and access the linked page.

How do you link a URL to text? ›

Add a hyperlink to existing text
  1. Select the text that you want to turn into a hyperlink, and right-click it.
  2. On the shortcut menu, click Hyperlink.
  3. In the Insert Hyperlink dialog, paste the link in the Address box and click OK.


1. HTTP to HTTPS redirect : URL Rewrite in IIS 8 Windows Server 2012 Part 5 : SSL Certificate
(Sachin Samy)
2. IIS 7 - Install URL Rewrite module
3. Examples of my most useful IIS rewrite rules
4. Remove .aspx extension from url’s using URL Rewrite in IIS 8 for
(Sachin Samy)
5. Basic URL Rewrite with Mod_Rewrite
6. IIS URL Rewrite for Username (Great for sites that only want the URL to be
(Dark Effects Studios)
Top Articles
Latest Posts
Article information

Author: Tuan Roob DDS

Last Updated: 03/08/2023

Views: 6360

Rating: 4.1 / 5 (62 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Tuan Roob DDS

Birthday: 1999-11-20

Address: Suite 592 642 Pfannerstill Island, South Keila, LA 74970-3076

Phone: +9617721773649

Job: Marketing Producer

Hobby: Skydiving, Flag Football, Knitting, Running, Lego building, Hunting, Juggling

Introduction: My name is Tuan Roob DDS, I am a friendly, good, energetic, faithful, fantastic, gentle, enchanting person who loves writing and wants to share my knowledge and understanding with you.