Entry
How do I turn a php script into index.html
Jul 9th, 2004 11:38
Philip Olson, Paul,
This question could have a few different meanings so we'll cover both.
First, the key here is the extension and of course .html is the
extension of index.html For the web server to have PHP process
the .html extension you must tell it to do so. For Apache the
following is a common configuration in httpd.conf:
AddType application/x-httpd-php .php .php3 .phtml
That will have PHP parse .php .php3 and .phtml extensions. In order to
have .html you could simply add it:
AddType application/x-httpd-php .php .php3 .phtml .html .example
As an example we made it so .example extensions also parse PHP, feel
free to remove that. Save, restart Apache, and now all .html files
(such as index.html) will be parsed as PHP.
Now let's say you don't want the overhead of parsing ALL .html files as
PHP but rather you want your web server to look for index.php in the
directory and load it if it exists, you could do the following in your
httpd.conf
DirectoryIndex index.php index.html index.htm example.php
That will first look for index.php, then index.html, then index.htm,
then example.php, in that order. Feel free to remove or add as you see
fit.