Simon Willison’s Weblog

Subscribe

Neat tip for clean URLs

6th August 2003

Here’s one of the neatest tips for clean URLs I’ve seen yet, from Thijs van der Vossen. He’s come up with a mod_rewrite rule that checks to see if the requested file exists if you add .html on to the end of it, and serves it up if that’s the case. I’m posting the full code snippet here because it’s just too good to risk losing to link-rot in the distant future:

RewriteEngine on 
RewriteBase /
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.*) $1\.html [L] 

This is Neat tip for clean URLs by Simon Willison, posted on 6th August 2003.

Next: Notepad popups

Previous: More links

Previously hosted at http://simon.incutio.com/archive/2003/08/06/cleanURLtip