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

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

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:

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

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

About Chris

Python developer, Agile practitioner trying desperately not to be a pointy haired boss.
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
    as it’s better then Google for this type of topic.

Comments are closed.