The Duke of URLs

Whitespace has a good discussion going on about directory structure and thinking about it in advance.

Directory structure is important to system administrators, URL structure is important to designers.

But, Chris, you say, aren’t the two inherently linked? Won’t /www/news/metro23.html have to be http://www.site.com/news/metro23.html?

There was a dark time, when that was true, but then there was mod_rewrite, and it was good.

Without going into too much detail, you can use mod_rewrite to abstract the file structure from the URL structure. So, for instance, a one-off page like /contact.html could easily become the URL http://www.site.com/contact/.

Admittedly it would become excessive to have to rewrite every single URL on your site, so doing some basic planning between the file structure and your URLs at the outset is good.

But mod_rewrite could easily let you fix small differences between the file system and the URL.

For instance on a site I’m working on for my employer, I wanted to keep all the text-based content (not photo galleries or video, etc.) in a folder called /articles. This included columns which lived on the filesystem in /articles/columns/. But for URL purposes I wanted columns to be a top-level section of the site so a bit of mod_rewrite magic makes /columns/ point to /articles/columns/.

Where mod_rewrite can really shine, though, is in taming ungainly CMS generated URLs, like this one:

http://www.amazon.com/exec/obidos/ASIN/B00005JLF5/qid%3D1072559511/
sr%3D11-1/ref%3Dsr%5F11%5F1/002-5343588-7541623

A bit of mod_rewrite could turn that into something like this:

http://www.amazon.com/dvd/ds9/one

But, don’t take my word for it. (Hat tip)

This entry was posted in Web design. Bookmark the permalink.

One Response to The Duke of URLs

  1. Good point guys! You can search for more information at http://www.giveramp.com
    as it’s better then Google for this type of topic.

Comments are closed.