top of page
rifascadownde

Learn how to use URL Rewrite 2.0 with Microsoft Learn: Download the module and follow the tutorials



How to Download and Use URL Rewrite 2.0 for IIS




If you are looking for a way to create user-friendly and search engine friendly URLs for your web applications, you might want to consider using URL Rewrite 2.0 for IIS. URL Rewrite 2.0 is a module that enables web administrators to create powerful rules to implement URL rewriting behavior based on various criteria, such as HTTP headers, server variables, regular expressions, and more. In this article, we will show you how to download, install, and use URL Rewrite 2.0 for IIS.




download url rewrite 2.0



What is URL Rewrite 2.0 and why do you need it?




URL Rewrite 2.0 is an incremental release of the URL Rewrite module for IIS that adds support for .NET extensibility and outbound response rewriting. It can be used to:


  • Implement complex rewrite logic by using 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



  • Modify the links in the HTML markup generated by a web application behind a reverse proxy



  • Fix up the content of any HTTP response by using regular expression pattern matching



  • Modify HTTP request and response headers and IIS server variables



By using URL Rewrite 2.0, you can improve the usability, performance, and security of your web applications.


URL Rewrite 2.0 features and benefits




URL Rewrite 2.0 includes the following key features:


  • Custom rewrite providers: The rewrite providers can be used when an URL rewrite logic cannot be expressed in terms of regular expression patterns or when it is required to make rewriting decisions based on data stored outside of web.config file (e.g. SQL database or text files). Customer rewrite providers can be implemented in any .NET language.



  • Rules-based response rewriting engine: Outbound rules are used to express the logic of what to compare parts of the response with and what to do if comparison was successful. Web server and site administrators can use outbound rules to define complex response rewriting logic.



  • Rewriting within the content of specific HTML tags: Instead of scanning the entire response for a particular match, the rule can be configured to look only inside of certain HTML tags, such as , , etc. That way the pattern is greatly simplified and the process of applying the rule to the content is much faster comparing to applying the pattern to the entire response.



  • Pre-conditions for outbound rules: Applying rewrite rules on every response is an expensive operation and is not necessary in majority of the cases. Pre-conditions are used to check the response metadata to determine if outbound rules evaluation should be applied.



  • Rewriting of server variables and HTTP request headers: Various IIS server variables and HTTP request headers can be set by using rewrite rules.



  • Rewriting of HTTP response headers: Outbound rewrite rules can be used modify any existing HTTP response headers or to set new ones.



  • Allow list for server variables: To prevent distributed rewrite rules from accidentally or purposefully modifying IIS server variables that may affect security or runtime behavior of a web application the modifiable server variables now have to be explicitly added to the allow list.



  • HtmlEncode function: Outbound rewrite may often use an un-trusted data (e.g. query string parameters) as part of the rewritten URL. To prevent cross-site scripting attacks the HtmlEncode function can be used to encode the data before it is used in the rewritten URL.



  • Logging of rewritten URLs: The module can be configured to log the original and rewritten URLs for each request. This can be useful for debugging and troubleshooting purposes.



URL Rewrite 2.0 offers the following benefits:


  • Improved SEO: By using URL Rewrite 2.0, you can create more descriptive and user-friendly URLs that can improve your site's ranking and visibility on search engines.



  • Enhanced user experience: By using URL Rewrite 2.0, you can provide your users with more intuitive and memorable URLs that can increase their engagement and retention.



  • Simplified web application development: By using URL Rewrite 2.0, you can decouple your web application logic from the URL structure, making it easier to maintain and update your code.



  • Increased security: By using URL Rewrite 2.0, you can prevent malicious users from exploiting vulnerabilities in your web application by hiding sensitive information from the URL or by encoding un-trusted data before using it in the URL.



URL Rewrite 2.0 requirements and compatibility




To use URL Rewrite 2.0, you need to have the following:


How to download url rewrite 2.0 for IIS 7 and above


Download url rewrite 2.0 module for Microsoft IIS site


URL rewrite 2.0 features and installation guide


Using url rewrite 2.0 to create SEO friendly URLs


URL rewrite 2.0 custom rewrite providers in .NET


Outbound response rewriting with url rewrite 2.0


URL rewrite 2.0 rules-based rewriting engine


URL rewrite 2.0 support for regular expression patterns


URL rewrite 2.0 rewriting of server variables and HTTP headers


URL rewrite 2.0 pre-conditions and allow list for server variables


URL rewrite 2.0 HtmlEncode function and outbound rules


URL rewrite 2.0 rule templates and rewrite maps


URL rewrite 2.0 integration with IIS manager and failed request tracing


URL rewrite 2.0 user-mode and kernel-mode caching


URL rewrite 2.0 reverse proxy rule template


Download url rewrite 2.0 extensibility samples and documentation


URL rewrite 2.0 wildcard pattern matching and substitution


URL rewrite 2.0 comparison with mod_rewrite and ISAPI_Rewrite


URL rewrite 2.0 troubleshooting and debugging tips


URL rewrite 2.0 performance and scalability best practices


Download url rewrite 2.0 for Azure web sites and cloud platform


URL rewrite 2.0 examples and scenarios for web applications


URL rewrite 2.0 compatibility with ASP.NET routing and MVC


URL rewrite 2.0 configuration reference and schema


URL rewrite 2.0 security considerations and recommendations


Download url rewrite 2.0 for Windows Server 2019 and IIS 10


URL rewrite 2.0 migration tool from Apache mod_rewrite


URL rewrite 2.0 feedback and support forum


URL rewrite 2.0 release history and version information


URL rewrite 2.0 license agreement and terms of use


Download url rewrite 2.0 for Windows Server Core installation option


URL rewrite 2.0 advanced settings and options


URL rewrite 2.0 testing and validation tools


URL rewrite 2.0 benefits and advantages for web administrators


URL rewrite 2.0 limitations and known issues


Download url rewrite 2.0 for IIS Express development server


URL rewrite 2.0 dynamic compression module compatibility issue workaround


URL rewrite 2.0 case sensitivity and normalization options


URL rewrite 2.0 logging and tracing options


URL rewrite 2.0 backup and restore configuration settings


Download url rewrite 2.0 for Windows Vista or Windows XP with IIS7.x installed


URL rewrite 2.0 globalization and localization support


URL rewrite 2.0 conditional match types and operators


URL rewrite 2.0 canonical domain name rule template


Download url rewrite 2.1 update package


URL Rewrite Module Configuration Reference Microsoft Learn


  • IIS 7 or above on Windows Server 2008 or above, or Windows Vista or above



  • .NET Framework 2.0 or above



  • Administrator privileges on the server



URL Rewrite 2.0 is compatible with the following IIS modules and features:


  • Application Request Routing (ARR)



  • FastCGI



  • Web Farm Framework (WFF)



  • Output Caching



  • Failed Request Tracing



How to download and install URL Rewrite 2.0




Downloading URL Rewrite 2.0 from the official website




You can download URL Rewrite 2.0 from the official Microsoft website at . There are two versions available: one for x86 systems and one for x64 systems. Make sure you download the correct version for your server architecture.


Installing URL Rewrite 2.0 using the setup wizard




To install URL Rewrite 2.0 using the setup wizard, follow these steps:


  • Run the downloaded executable file as an administrator.



  • Accept the license agreement and click Next.



  • Select the destination folder and click Next.



  • Click Install to begin the installation.



  • Click Finish to complete the installation.



Verifying the installation of URL Rewrite 2.0




To verify that URL Rewrite 2.0 has been installed successfully, follow these steps:


  • Open IIS Manager by clicking Start > Administrative Tools > Internet Information Services (IIS) Manager.



  • Select your server node in the Connections pane.



  • In the Features View, look for the URL Rewrite icon under IIS section. If you see it, then URL Rewrite 2.0 has been installed successfully.



How to use URL Rewrite 2.0 for IIS




Creating and managing rewrite rules using IIS Manager




You can create and manage rewrite rules using IIS Manager by following these steps:


  • Select the site or application for which you want to create a rewrite rule in the Connections pane.



  • In the Features View, double-click the URL Rewrite icon.



  • In the Actions pane, click Add Rule(s) to open the Add Rule dialog box.



  • Select the rule template that matches your scenario, such as Blank Rule, User-friendly URL, or Redirect. You can also create your own custom rule by selecting Custom Rule.



  • Enter the name and description of your rule in the Name and Description fields.



  • Specify the pattern and conditions for matching the request URL in the Match URL and Conditions sections. You can use regular expressions, wildcards, or exact matches to define your pattern and conditions.



  • Specify the action to take when the rule is matched in the Action section. You can choose to rewrite, redirect, abort, or perform a custom action on the request URL.



  • Optionally, you can specify additional settings for your rule in the Advanced Settings section, such as server variables, rewrite maps, logging, and pre-conditions.



  • Click Apply to save your rule.



You can edit, delete, disable, or test your rules by selecting them in the URL Rewrite feature page and using the options in the Actions pane.


Creating and managing rewrite rules using web.config file




You can also create and manage rewrite rules using the web.config file of your site or application. The web.config file is an XML file that stores the configuration settings for your site or application. To create and manage rewrite rules using web.config file, follow these steps:



  • Open the web.config file of your site or application using a text editor or a web development tool such as Visual Studio.



  • Locate the section in the web.config file. If it does not exist, create it.



  • Within the section, locate or create a section. This is where you will define your rewrite rules.



  • Within the section, create a section. This is where you will add your rewrite rules.



  • For each rewrite rule, create a element with a name attribute that specifies the name of your rule. Within the element, specify the following sub-elements:



  • : This element specifies the pattern to match the request URL. You can use regular expressions, wildcards, or exact matches to define your pattern.



  • : This element specifies a list of conditions that must be met for the rule to be applied. You can use logical operators such as AND and OR to combine multiple conditions. Each condition is defined by an element that specifies the input value to compare, an attribute that specifies how to compare it (such as matchType or pattern), and an optional negate attribute that specifies whether to invert the comparison result.



  • : This element specifies the action to take when the rule is matched. You can choose to rewrite, redirect, abort, or perform a custom action on the request URL. You can also specify additional attributes such as url, appendQueryString, redirectType, statusCode, statusReason, statusDescription, etc., depending on the type of action.



  • Optionally, you can specify additional settings for your rule by using other sub-elements within the element, such as , , , and .



  • Save your web.config file and restart your site or application for the changes to take effect.



You can edit, delete, disable, or test your rules by modifying them in the web.config file and saving it.


Using custom rewrite providers written in .NET




If you need to implement complex rewrite logic that cannot be expressed in terms of regular expression patterns or when you need to make rewriting decisions based on data stored outside of web.config file (e.g. SQL database or text files), you can use custom rewrite providers written in .NET. Custom rewrite providers are classes that implement the IRewriteProvider interface and are registered in the web.config file. You can use custom rewrite providers in your rewrite rules by using the RewriteProvider function in the pattern or action elements. To use custom rewrite providers written in .NET, follow these steps:



  • Create a class library project in Visual Studio and add a reference to Microsoft.Web.Iis.Rewrite.dll assembly.



  • Create a class that implements the IRewriteProvider interface and override the Initialize and Rewrite methods. The Initialize method is called once when the provider is loaded and can be used to initialize any provider-specific settings or resources. The Rewrite method is called for each request that uses the provider and takes an input value and returns an output value based on the provider logic.



  • Build your project and copy the output assembly to the bin folder of your site or application.



  • Open the web.config file of your site or application and locate or create the section within the section.



  • Within the section, create a section. This is where you will register your custom rewrite providers.



  • For each custom rewrite provider, create an element with a name attribute that specifies the name of your provider. Within the element, specify the following attributes:



  • type: This attribute specifies the fully qualified type name of your provider class, including the assembly name.



  • Any other custom attributes that you need to pass to your provider class.



  • Save your web.config file and restart your site or application for the changes to take effect.



  • To use your custom rewrite provider in your rewrite rules, use the RewriteProvider function in the pattern or action elements of your rules. The syntax of the RewriteProvider function is as follows:



RewriteProvider(providerName, inputValue)


where providerName is the name of your registered provider and inputValue is the value to pass to the provider's Rewrite method.


Using outbound rules to rewrite response content and headers




If you need to modify the content or headers of the HTTP response generated by your web application, you can use outbound rules to rewrite them based on various criteria. Outbound rules are similar to inbound rules, except that they are applied after the request is processed by the web application and before it is sent back to the client. To use outbound rules to rewrite response content and headers, follow these steps:



  • Select the site or application for which you want to create an outbound rule in the Connections pane.



  • In the Features View, double-click the URL Rewrite icon.



  • In the Actions pane, click Add Rule(s) to open the Add Rule dialog box.



  • Select Outbound Rule as the rule template and click OK.



  • Enter the name and description of your rule in the Name and Description fields.



  • Specify the scope of your rule in the Precondition section. You can choose to apply your rule to all responses, responses with specific content types, responses with specific status codes, or responses that match a custom precondition that you define.



  • Specify the pattern and conditions for matching the response content or headers in the Match section. You can use regular expressions, wildcards, or exact matches to define your pattern and conditions.



  • Specify the action to take when the rule is matched in the Action section. You can choose to rewrite, delete, or modify the response content or headers. You can also specify additional attributes such as value, replace, or append depending on the type of action.



  • Optionally, you can specify additional settings for your rule in the Advanced Settings section, such as server variables, rewrite maps, logging, and pre-conditions.



  • Click Apply to save your rule.



You can edit, delete, disable, or test your rules by selecting them in the URL Rewrite feature page and using the options in the Actions pane.


Using pre-conditions and server variables for outbound rules




Pre-conditions are used to check the response metadata to determine if outbound rules evaluation should be applied. Pre-conditions can improve the performance and security of your outbound rules by avoiding unnecessary processing of responses that do not need to be rewritten. To use pre-conditions for outbound rules, follow these steps:



  • Select the site or application for which you want to create a pre-condition in the Connections pane.



  • In the Features View, double-click the URL Rewrite icon.



  • In the Actions pane, click Add Precondition to open the Add Precondition dialog box.



  • Enter the name of your pre-condition in the Name field.



  • Specify the logical grouping of your pre-condition in the Logical Grouping section. You can choose to match all or any of the conditions that you define.



  • Specify the conditions for your pre-condition in the Conditions section. You can use various response attributes such as content type, status code, header value, etc., to define your conditions. Each condition is defined by an element that specifies the input value to compare, an attribute that specifies how to compare it (such as matchType or pattern), and an optional negate attribute that specifies whether to invert the comparison result.



  • Click OK to save your pre-condition.



  • To use your pre-condition in your outbound rules, select it from the Precondition drop-down list in the Precondition section of your rule settings.



Server variables are used to store and retrieve information about the request and response during URL rewriting. Server variables can be used in both inbound and outbound rules as input values or output values. To use server variables for outbound rules, follow these steps:



  • Select the site or application for which you want to use a server variable in the Connections pane.



  • In the Features View, double-click the URL Rewrite icon.



  • In the Actions pane, click View Server Variables to open the Server Variables dialog box.



  • To add a new server variable, click Add in the Actions pane and enter the name of your server variable in the Name field. Click OK to save your server variable.



  • To edit or delete an existing server variable, select it from the list and use the options in the Actions pane.



  • To use your server variable in your outbound rules, use the syntax SERVER_VARIABLE_NAME in the input or output values of your rule settings.



Conclusion and FAQs




In this article, we have shown you how to download, install, and use URL Rewrite 2.0 for IIS. URL Rewrite 2.0 is a powerful module that enables you to create and manage rewrite rules for your web applications. You can use URL Rewrite 2.0 to improve the SEO, usability, performance, and security of your web applications. You can also use URL Rewrite 2.0 to implement complex rewrite logic by using custom rewrite providers written in .NET or by using outbound rules to rewrite response content and headers. We hope you have found this article helpful and informative. If you have any questions or feedback, please feel free to contact us.


Here are some frequently asked questions about URL Rewrite 2.0:


Q: How can I migrate my existing rewrite rules from URL Rewrite 1.1 to URL Rewrite 2.0?




A: You can migrate your existing rewrite rules from URL Rewrite 1.1 to URL Rewrite 2.0 by using the Import Rules feature in IIS Manager. To do this, follow these steps:


  • Select the site or application for which you want to import the rewrite rules in the Connections pane.



  • In the Features View, double-click the URL Rewrite icon.



  • In the Actions pane, click Import Rules to open the Import Rules dialog box.



  • Browse to the web.config file that contains your rewrite rules from URL Rewrite 1.1 and click OK.



  • Review the imported rules and make any necessary changes or adjustments.



  • Click Apply to save your imported rules.



Q: How can I troubleshoot my rewrite rules in URL Rewrite 2.0?




A: You can troubleshoot your rewrite rules in URL Rewrite 2.0 by using the Test Pattern feature in IIS Manager or by using the Failed Request Tracing feature in IIS. To use the Test Pattern feature, follow these steps:


  • Select the site or application for which you want to test the rewrite rules in the Connections pane.



  • In the Features View, double-click the URL Rewrite icon.



  • Select the rule that you want to test and click Edit in the Actions pane.



  • In the Edit Rule dialog box, click Test Pattern to open the Test Pattern dialog box.



  • Enter a sample request URL in the Input data field and click Test.



  • Review the test results and see if they match your expectations.



To use the Failed Request Tracing feature, follow these steps:


  • Enable Failed Request Tracing for your site or application by following .



  • Configure a trace rule for your site or application by following .



  • Reproduce the issue that you want to troubleshoot by sending a request to your site or application.



  • Open the trace log file that is generated by Failed Request Tracing and analyze it for any errors or warnings related to URL Rewrite 2.0.



Q: How can I update URL Rewrite 2.0 to the latest version?




A: You can update URL Rewrite 2.0 to the latest version by downloading and installing it from . You do not need to uninstall the previous version before installing the new one. The new version will overwrite and replace the old one. The new version will preserve your existing rewrite rules and settings.


Q: How can I uninstall URL Rewrite 2.0 from my server?




A: You can uninstall URL Rewrite 2.0 from your server by following these steps:


  • Open Control Panel and click Programs and Features.



  • Select URL Rewrite 2.0 from the list of installed programs and click Uninstall.



  • Follow the instructions in the uninstall wizard to complete the uninstallation.



Q: Where can I find more information and resources about URL Rewrite 2.0?




A: You can find more information and resources about URL Rewrite 2.0 at the following links:


  • : This is the official documentation page for URL Rewrite 2.0, where you can find detailed information about the module features, configuration, and usage scenarios.



  • : This is the official reference page for URL Rewrite 2.0, where you can find the syntax and examples of the rewrite rules, conditions, actions, functions, providers, and server variables.



  • : This is the official forum for URL Rewrite 2.0, where you can ask questions, share tips, and get support from other users and experts.



  • : This is the blog of Ruslan Yakushev, the program manager for URL Rewrite 2.0, where you can find news, updates, and tutorials about the module.



44f88ac181


1 view0 comments

Recent Posts

See All

Comments


bottom of page