Cleaning up your sites URLs with the URL Rewrite Filter
March 31, 2007 – 7:37 pmDuring the development of our first ‘real’ site, http://www.myfriendsuggests.com, we never really paid too much attention to the URLs that our site was generating. We did some reading and heard that clean URLs were important for SEO reasons but at the same time we saw the GoogleBot crawling our site just fine, so we ignored it. After reading articles like “The Importance of a Semantic URL” we’ve decided to start the process of cleaning up our sites URLs. Instead of using mod_rewrite which forces us to be dependent on apache, we decided to try the URL Rewrite Filter. This tool is a Java based Servlet Filter which makes cleaning up the URLs easy. The hard part is throughout our site we reference the old URL string. What we’ve been doing is adding simple rewrite rules like the following:
<rule>
<from>dest([0-9]+).html</from>
<to>/Destination.jsp?dest=$1</to>
</rule>
This rule will forward any requests to lets say dest59.html to /Destinations.jsp?dest=59 . This part was pretty easy, but the problem was that the Destination.jsp url was found throughout our site in various forms (one of the other negatives to not setting up good conventions up front). I’ve used PowerGrep to replace the references through the site and now am in the testing phase to make sure this all works properly.
I will continue to change a few pages over to this new cleaner URL format while we continue other development and will upate the blog to let others know if this really had a positive effect on our site as a whole.
Plan Early
One thing I learned is that by not planning what the URLs will look like early I have to do a lot of refactoring of the site. For anyone doing web development from scratch be sure to plan this important aspect of your site out.
java jsp MyFriendSuggests Technorati Web 2.0
