The element above tells the URL Rewrite Module to end the HTTP request. In other words, the condition verifies that the host header does not match "localhost". The element above adds a condition to the rule that retrieves the host header value by reading the server variable HTTP_HOST, matches it against the pattern "localhost" and then negates the result of matching. The element above says that the rule will match any URL string. Let's analyze the rule to understand what it does. The section should look like the following code: Insert the following rule into the collection, so that it is the first rule in the collection: Open the Web.config file in the %SystemDrive%\inetpub\Locate the section. We will create this rule without using IIS Manager. This type of rule is useful when you want to prevent hacking attempts that are made by issuing HTTP requests against the IP address of the server instead of using the host name. The third rule that we will create is used to block all requests made to a Web site if those requests do not have the host header set. You should see that the browser was redirected to as a result of redirect rule execution and then the request was rewritten in accordance with the rewrite rule that you have created earlier. To test that the rule redirects requests correctly, open a Web browser and request the following URL: Save the rule by clicking Apply on the right-hand side. Leave default values for all other settings. In the Rewrite URL: text box, enter the following string: article.aspx?id= (This substitution string will be used as a redirect URL notice that it uses back-references to preserve and rearrange the original URL pieces captured during pattern match.)Įnter the name, pattern, and action as shown below: Since the rule that we are creating is supposed to rewrite the URL, choose the Rewrite action type that is listed in the Action group box. These parentheses create capture groups, which can be later referenced in the rule by using back-references. Notice that certain parts of the regular expression are within parentheses.
URL REWRITE DOWNLOAD CODE
This page reads the Web server variables and outputs their values in the browser.Ĭopy the following ASP.NET code and put it in the % SystemDrive%\inetpub\ To demonstrate how the URL Rewrite Module works, we will use a simple test ASP.NET page. For more information, see Using the URL Rewrite Module.
URL REWRITE DOWNLOAD HOW TO
This walkthrough will guide you through how to create and test a set of rewrite rules for the URL Rewrite Module.
URL REWRITE DOWNLOAD DOWNLOAD
The URL rewrite module is an extension to IIS which is available as a download for your stand-alone IIS Server, and is also pre-installed on any website on Windows Azure Web Sites (WAWS) and available for your use.