How to request PHP pages as if they were .html files?


Suppose you would like your PHP pages to masquerade as .html files. How would you accomplish that?

If you are running PHP on the Apache web server platform, you can take advantage of issuing server directives from an .htaccess file in the root web folder or in any sub folder.

Include in you .htaccess file:

AddType application/x-httpd-php .html

If you are running PHP through a ‘script wrapper’ the code would look something like this:

Action application/x-myhost-sphp4 /cgi-bin/php-cgiwrap/myaccountname/php4.cgi
AddType application/x-myhost-sphp4 .php .html

You need to consult your individual hosting provider for details on how to invoke the wrapper, if any.


just adding to this.

Using htacess is also great for creating your own extensions. for example on my site i use .dnx to parse as .php files.

I’ve created 3 variations:

.dnx --> Main files with design work
.idnx --> Includes with just code
.cdnx --> Class files with functions in them.