Excessively long URLs.

I hate unnecessarily long URLs. One of the things I always try to figure out how to leave out is the file name extension. As Tim Berners-Lee says:

"cgi", even ".html" is something which will change. You may not be using HTML for that page in 20 years time, but you might want today's links to it to still be valid. The canonical way of making links to the W3C site doesn't use the extension

Here are two ways of doing this with Apache.

  1. Insert this line into your ".htaccess" file:

    DefaultType text/html

Then when you create any new html pages, call them "foobar" instead of "foobar.html" and then your URL will be:


and not


Which makes more sense. Now you can at some later point in time change the default to .shtml or .php

  1. Put this in your ".htaccess" file:

    Options All MultiViews

Then put a file called "foobar.html" in the directory "directory/" and the URL:


will automagically work.

Other options:

  1. Here's a third way:

    RewriteEngine on RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^(.*)$ $1.html