ASP.NET URL Rewriting

URL rewriting makes URLs much clearer for people and for SEO. For example, a URL such as http://www.example.com/product?id=34849284382409 does not mean much to the average computer user, although to a web developer we know it’s passing a parameter. Having a URL such as http://www.example.com/product/34849284382409 is much clearer and is better for SEO.

URL rewriting is quite easy to add, and we are going to do this through IIS GUI. Before we begin you should know how to add a website to IIS; if you don’t search Google and review it. Next, download the URL rewrite module from http://www.iis.net/download/urlrewrite from the links on the right, or you can use the Microsoft Web platform installer to download it.

Now, open up IIS (just type IIS in the Windows search bar).

You should see your websites on the left and the URL rewrite module installed.

Internet Information Services

Next click on one of your websites, click URL Rewrite and then at the top right click Add Rules. This dialogue shows:

Add URL Rewrite Rule

Next, click User-Friendly-URL.

Now fill out the form, give it a URL with a parameter such as http://www.example.com/wiki?id=3, and from the list choose the URL you prefer. Make sure outbound and redirect are checked, as this will redirect users if they directly type in something like wiki?id=3.

Here is the image:

IIS Rewrite Rule Type

This will only work for the wiki page, however if someone goes to category?id=3 it will not redirect category/3. You need to add a rule for each page which requests an ID.

Finally, click on Add Rules and towards the bottom you will see “Enforce Lower-Case URLs”. ASP.NET allows upper case or lower case URLs, however URLs are case-sensitive and search engines will pick them up twice. It is recommended that you add this rule: just click the rule and a message will appear, and click OK.