Wednesday, August 22, 2007

No PHPeeking!

One thing that really gets my goat is when a website's URLs expose the underlying processing engine used to generate the content of the page, rather than reflecting the content type of the page itself. For example, "about.php" instead of about.html. Who in the world needs to know that PHP generated the page after it's already been rendered as HTML. (I don't mean to pick on the PHP developers out there. Of course, ASP and Java Servlet users are just as guilty of this nonsense.)

Fundamentally, a URL is part of the user interface of a web page. The user can almost always see the URL, can always bookmark it for later reference, and sometimes wants to be able to remember it. There are plenty of other URL naming conventions that should be followed to ensure a high level of usability on a website, but hiding the engine from the user is generally a simple process that can often be automated using three lines. Drop the following "code" into a .htaccess file, which is supported almost every web host running the Apache web server, in the root of your website:
    RewriteEngine on

# If requested .html file doesn't exist, rewrite to .php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html$ $1.php [T=application/x-httpd-php]
Now why don't more people do that?

Labels: , , ,

2 Comments:

At 6:05 PM , Blogger suzy said...

when did your blog become a computer nerd blog? i wanted to hear about israel, not html!
are you still on a sailboat?
call me sometime (when you're back in the US?)

 
At 7:17 PM , Blogger Dov said...

You finally made it to Israel albeit w/o luggage... let's hear all about ur travel adventures.

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home