Wednesday, September 15, 2010

Url Rewriting Made Easy - Article 3

After implementing URL Rewriting there are certain issues which we need to tackle, so that URL rewriting logic will not affect web application. This is I am talking with reference to URL Rewriting for Search Engine Optimization, where we are preferring hackable URLs.
This article is continuation of my previous articles on URL Rewriting.
  1. Url Rewriting Made Easy- Article 1 (Demo Code)
  2. Url Rewriting Made Easy- Article 2 (Demo Code)
Basic things which I considered while developing logic was, Url Rewriting should be very simple to understand and implement. And it should be considered while developing the web application and not after completing the development.
What happens when we do URL Rewriting? On the client side i.e. on Browser we display URL which is hackable (i.e. Easy to understand and can be remembered easily, which also directly or indirectly displays directory structure.). On server side page get redirected to some other page using query string and rest of the operations can be performed in normal way. But There is one serious thing which we need to consider, normally when we Use Images and JavaScript files in HTML logic we tend to give relative path; and this path is picked by browsers to display images and include JavaScript files in HTML code.
In case of URL Rewriting we have discussed in Article 1 and Article 2, we need to keep work around for images and JavaScripts. As per the logic Raw Urls (i.e. Hackable URL) is being displayed and used by the browser, but for displaying Images which belongs to different folder we need to use fully qualified urls.
USE FULLY QUALIFIED URLS FOR IMAGES AS WELL AS TO INCLUDE JAVA SCRIPT FILES, SO THAT URL REWRITING CAN WORK. You can always go for Image Handlers or manipulate Image Urls by making Images server side controls. for including JavaScripts you can either Manipulate the Head Section Dynamically or use your own logic.
Submit this story to DotNetKicks

0 comments: