background preloader

Url rewrite

Facebook Twitter

Introduction to URL Rewriting using IIS URL Rewrite Module and Regular Expressions. Introduction In this blog post we'll talk about URL Rewriting and how it can be done using Microsoft's IIS. Why IIS? Because there are not that many tutorials that cover that stuff. Also, some very experienced PHP developers don't know how to rewrite URLs if their page is hosted on IIS.

URL Rewriting? URL Rewriting basically means: altering the URL's apperance without affecting behaviour of your site. Well, there are couple of great reasons. With this one: What are the advantages of URL number two? Of course, there's another great advantage of URL Rewriting: original query strings used to retrieve blog posts can change and the rewritten URL can stay the same. Also, don't forget the security factor of rewritten URLs: they hide how site works, meaning users don't really know what query strings are used and what is happening behind the scenes. OK, now we know URL Rewriting is great. URL Rewriting on Microsoft IIS URL Rewrite is a module for Microsoft IIS. Installation using WPI Testing the rule. Creating Rewrite Rules for the URL Rewrite Module. 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.

Creating Rewrite Rules for the URL Rewrite Module

This walkthrough will guide you through how to create and test a set of rewrite rules for the URL Rewrite Module. Prerequisites This walkthrough requires the following prerequisites: IIS 7 or above with ASP.NET role service enabled.URL Rewrite Module installed. For more information, see Using the URL Rewrite Module. Setting up a test Web page To demonstrate how the URL Rewrite Module works, we will use a simple test ASP.NET page. Copy the following ASP.NET code and put it in the %SystemDrive%\inetpub\wwwroot\ folder in a file called article.aspx: <%@ Page Language="C#" %><! After copying this file, browse to and check that the page was rendered correctly in a browser.

Creating a rewrite rule We will create a simple rewrite rule that will rewrite URLs using the following format: URL Rewrite Module Configuration Reference. This article provides an overview of the URL Rewrite Module and explains the configuration concepts that are used by the module.

URL Rewrite Module Configuration Reference

Table Of Contents Functionality Overview The URL Rewrite Module rewrites request URLs to simple, user-friendly, and search-engine friendly addresses that are displayed to users or in Web applications. URL Rewrite uses defined rules to evaluate and then map the request URL to the address defined in the rule before it is processed by an IIS Web server. You can define URL rewriting logic that includes regular expressions and wildcards, and rules can be applied based on the request URL, HTTP headers, and server variables. Rewrite Rules Overview A rewrite rule defines the logic of what to compare or match the request URL with, and what to do if the comparison is successful. Rewrite rules consists of the following parts: Pattern – The rule pattern is used to specify either the regular expression or a wildcard pattern that is used to match URL strings.