WebMasterSam

.Net, SEO, Dynamics CRM, AdSense/AdWords, Dating sites, Silverlight, Web hosting and more

About me

I'm an IT consultant working primarily with the .Net Framework as a developper and architect. I also work on my own on my personnal dating websites. I've been developping websites since 2000.

If you like what I do, feel free to support me

PayPal - The safer, easier way to pay online!

Bookmark

Bookmark and Share

Last comments

None

Adding URL rewriting to my website; what do I need ?

First of all, if you're here you have a vague idea of what URL rewriting is and what it can add to your website.

The more relevant is your URL, the higher your rank will be on searches. If you submit a sitemap to Google with a lot of entries that all points to the same page with different querystring parameters, the search engine will not index all your pages and you will get warnings (on Google WebMaster Tools). So the best way is to always have unique URLs on your website, and if it's physically impossible, you can easily use URL rewriting.

Let me explain this with an example... if you have this url, http://www.yoursite.com/member.aspx?username=JohnSmith, you can rewrite it to be http://www.yoursite.com/members/JohnSmith. There is a lot of websites that uses URL rewriting. One of the most well-known is Wikipedia (here is an example of their URLs : http://en.wikipedia.org/wiki/ClickOnce).

Even if your actual querystring parameters are not string values, you can use URL rewriting efficiently. Let's say you have the following URL : http://www.yoursite.com/catalog/products.aspx?productid=123456, you can rewrite it to http://www.yoursite.com/catalog/product123456.aspx.

Now, how to include this in my website ? 

It's very easy to include URL rewriting in an existing website. Also, if you include URL rewriting, the old-fashioned way to access your pages will stay available, so you don't have to worry about adding URL rewriting on your production environment because you don't replace something, you add a functionnality.

URLRewriter is the most simple and powerful URL rewriting open source .Net component you can find on the web.

To configure it you simply have to add a custom section on your web.config file like this :


<rewrite url=?^(.*)/(\?.+)?$? to=?$1/default.aspx$2?? />

For example, if we write the XML .config tag for the first URL (JohnSmith) it would be :


<rewrite url=?^(.*)/members/(.+)$? to=?$1/member.aspx?username=$2? />

And for the second URL :


<rewrite url=?^(.*)/catalog/product(.+).aspx? to=?S1/catalog/products.aspx?productid=$2? />

What URL rewriting does is to take the URL in the "url" property of the "rewrite" config element and rewrite it to the format of the "to" property so that the real request you get is a request to you product.aspx page with the productid querystring parameter that you can retreive easily.

Posted: Apr 10 2009, 11:16 by WebMasterSam | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .Net | SEO
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
LINK BUILDING IS PROHIBITED ON THIS WEBSITE