[thelist] [PHP] Send it as plain html

Richard Harb rharb at earthling.net
Thu Nov 25 21:23:37 CST 2004

-----Original Message-----
From: Tim Burgan
Sent: Thursday, November 25, 2004, 11:40:32 PM
> Hello,

> I'm on a roll with my PHP questions of late.

> I saw somewhere within the last week, how to have a PHP page that the 
> browser actually thinks is html. It does everything PHP is supposed to 
> do on the server, but when it reaches the browser it has the .html 
> extension, not .php

apathetic already answered this one. I'd like to add that you can also do this
on a per directory basis using .htaccess files (provided your provider allows
usage of .htaccess and further allows overrides to FileInfo).

So in addition to the usually mapped filetype of php .html gets fed to the
interpreter as well. This induces a small overhead to all the html files, but
if there are no php statements in a particular file the overhead ought to be
managable (thus the advice to eventually use this on a per directory basis).

If your aim is to introduce more security through obscuring your use of php then
be advised that for somebody who wants to find out it's no use at all, because
the server usually gives it away in the header that a particular page was
processed with php (Some Firefox extension lets you easily check that, as well
as "wget -S URI").


If you intend to completely omit the ending, then that would work as well, but
requires (as has been stated in a previous post as well) that the Apache
webserver is configured to do that.

I recommend reading http://httpd.apache.org/docs-2.0/content-negotiation.html on
that topic.

A final note if the 'file extension-less' linking of pages serving images is
used (a php file for example serving .jpg for example). Apache doesn't have
problems seving those and if linked correctly a browser doesn't either. Just
some log file analyzers won't know about it and count those hits as pages.


More information about the thelist mailing list