Rewriting the URL of the Site using HTTP Modules

Hi

So after spending some time with the site one thing I realized that the next thing that needs to be done to the site was URL Rewriting. Now you can see the site working with URL Rewriting. I did not like having meaningless URL's for visitors (i.e. post.aspx?postid=3), and hence went for URL Rewriting.  I had worked on URL Rewriting on asp.net 1.1 so I decided to work on that library only. I use HTTP Modules for URL Rewriting (I know we have other option like IIS, HTTP Handler etc). The main reason for the decision was that I already had the library with me and it took only a couple of hours to complete the work (including creation of rules).

Now when you go to the index.aspx you are redirected to HomePage.aspx). Basically you go to the index.aspx but you will see the URL HomePage.aspx and same with other page like about.aspx and contact.aspx.  The individual posts have been named to their respective titles with some of the character replaced by other (like space has been replaced with "_").

The Biggest thing I had to think was about the rewrite rule of the Home page. I was using the index page for many tasks(like showing the Blogs based on category, year and month and showing search result). So what to do with, show all this different pages with the URL homepage. Well I decided against it and wrote some code to create a different rule for the homepage. So now when you want to see the Blogs for a category you will have the URL like <http:////www.vikramlakhotia.com//Personal.aspx> (Here personal is the name of the category). I felt it made more sense to have the category name as the Name of the page. For the search page you will have the URL as search.aspx (I find this as the most expressive) and a query string keyword showing the search term. This also tells the user what he searched for. For looking at the blogs in respect of months the URL would change to year_month. This will let the user understand which month's blogs he is watching and will be easy for him to switch to another month through the URL itself.

Special consideration was given to the Blogs detail page. As I said before the blog detail page will have the blog title as the URL. Spaces have been converted to ("_") underscore. I personally felt it's very easy to read the URL with ("_") underscore and it also makes sense for the user to see the title o the blog as the URL.

If you have any question or suggestions on the new URL, don’t hesitate.

Thanks
Vikram


Share this post   Email it

Feedback

Posted on 9/18/2006 7:31:47 AM

Do you plan on releasing some code for the articles you post?

Posted on 9/20/2006 1:22:45 AM

Yes Jerome Paradis I have plans to write a blog on how URL Rewriting can be achieved for any website. I will come up with the blog as soon as I get time

Posted on 10/6/2006 10:19:35 AM

THis is nice blogs but want to see how we can do it. would like to see that code.

Posted on 10/7/2006 9:25:42 PM

Yes I am also interested in seeing some code. I am particularly interested because it sounds like a light solution using HttpHandlers

Posted on 12/7/2006 5:07:02 AM

i want code for url rewriting plz send it..

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 

Copyright © 2006 - 2012 Vikram Lakhotia