Should URLs depend on underlying server technology?

I ran into an interesting problem when I was brushing up my web site lately. Let’s say I had a static HTML page named

Now, I decided to use some kind of cool technology (PHP, ASP, JSP, CGI, SSI, FBI, CIA, USA, well, you get the picture). This would work only if I rename page.html to page.php (.asp, .jsp, .fbi, …). This is how the web server knows what technology to apply when rendering the page. This, however, has at least two downsides:

  • The URL will change and external links will break. Not all external links are under my control.
  • People, including Evil Hacker People, will now know what technology I use to generate the page.

In the end I decided to use Apache URL rewrite feature to keep old URLs intact. It is quite easy to define in an .htaccess file in each web directory, but if you do something wrong, the rewriter quirks could be really annoying.

Here’s a couple of examples:

RewriteEngine on
RewriteRule ^foo\.html$ foo.php

RewriteEngine on
RewriteRule ^(.*)\.html$ $1.shtml

The people outside your server keep going to the old .html URL and the server does all the mapping seamlessly. A lot of rewrite rules will, of course, slow down a heavy loaded server, but a couple of rules here and there don't seem to hurt that much.

Leave a Reply

Your email address will not be published. Required fields are marked *