How .htaccess will help
The php3 / php4 switch has caused problems for some, here’s a bandaid. Worst case scenario is you already switched every reference of .php3 to .php in a few scripts, must be an easier way, right? Yes.
There are a few ways to overcome the issue of “broken” extensions and unwanted directory listings. Today we’ll focus on “virtual” accounts who must rely on .htaccess (this can be applied to configuration files such as http.conf though)
Let’s create our .htaccess
First, let’s get various extensions to parse php :
If your server is running php4 :
AddType application/x-httpd-php .php .php3 .html .phtml .foo
AddType application/x-httpd-php-source .phps .bar
If your server is running php3 :
AddType application/x-httpd-php3 .php .php3 .html .phtml .foo
AddType application/x-httpd-php3-source .phps .bar
Now, let’s get index.php to initially load vs. show the contents of the directory :
DirectoryIndex index.php index.html home.html foo.html
What the above means
First off, you now have various extensions that will parse php, you can add or remove them as you wish. So, when one enters blah.phtml , the php within blah.phtml will parse and everything will be happy. AddType source no doubt already exists but is thrown in for good measure so .phps will for sure display your code in pretty colors.
Next, we have DirectoryIndex, which simply means that when someone types in blah.com/blah/ it will check for index.php and if it exists, it will load. If it does not exist, it’ll check for index.html and whatever else you list here, in the order you provide. You’re in charge!
Conclusion
Your .htaccess should now contain three lines, two AddType applications and a DirectoryIndex. Enjoy running your .php3 and .php4 extensions!
All comments welcome, we’re all here to learn.
— Philip Olson, theprojects.org