Running PHP on a html or htm page
I’ve had to look this up more times than I can count. I think I’ve made a post to link to it, but it’d be easier for me if this was just here. I got this code from Christine who posted it on the Blogomania support forums ages ago. (side note: Those forums are mostly for people who are hosted on Blogomania - but obviously you’re free to peruse the info there)
To make your .htm or .html pages process like they were .php, just add this line to your .htaccess file:
April 2nd, 2003 at 10:08 pm
Heh, I could’ve used this bit of knowledge a few moanths ago. Oh well =)
April 2nd, 2003 at 11:24 pm
Ever needed to make a .htm or .html page act like a .php page? Maybe you have some php code…
April 3rd, 2003 at 2:20 pm
I’ve used this little piece of info myself in the past. I’ve downloaded some PHP programs where the extension of the scripts are all .php3. By just adding another type to the list, it saves you from having to rename all the scripts to the correct extension.
April 4th, 2003 at 11:10 am
Well, something should be mentioned here about choosing wisely. Let’s say that you choose to have all .html pages php-parsed. While the slowdown won’t be much per page, the pages WILL take a bit more time to load. You should weigh the slight slowdown on all pages against the value you get from this change. If you’re going to slow down quite a few pages for the benefit of just a couple, you’re probably better off converting those few pages to .php and leaving the others untouched.
April 6th, 2003 at 11:46 pm
Also, some servers parse .html and .htm pages automatically - that was why, when I first skinned my site using Amy’s instructions, I never realized the pages needed to be named .php. When I moved my site last April to where Blogomania now lives, everything broke and that was the fastest fix.
Someday I might see if I can rename everything .php - but then again, that would mess up everyone’s links and so forth - so I guess those few seconds are just it for right now…
May 2nd, 2003 at 4:08 pm
Or use:
RewriteEngine On
RewriteRule ^index.html /index.php
Inside your .htaccess file.
An excellent way of parsing PHP as HTML or .whatever so an overhaul of your site and URL rewriting in your .htaccess file will keep all your links the same. Sure to have some drawback along the way, maybe load speed and so on but then Apache isn’t perfect as it’s not made me a cuppa yet
August 9th, 2003 at 2:32 pm
I’m coming into this very late indeed, but am relieved to find this little gem
Thanks for sharing it 
Having recently skun my blog (skun? is that a word? hehe), I am interested in the actual functionality behind this… I assume that this searches for all instances of htm html and php, and just goes to the one that is there?
My blog is on a site with other blogs, so changing the htaccess file so that my php pages will be brought up when people type index.html, won’t affect the other pages who use index.html?
August 10th, 2003 at 10:17 pm
Katia - when you change an .htaccess file, it will affect that directory and any and all within that directory. If the other people who share your hosting space are within the directory where your edited .htaccess file resides - then they will be affected too. If they are in a seperate directory path - then they shouldn’t be affected.
August 11th, 2003 at 11:29 am
Ok, that’s brilliant - exactly what I needed to know
Thanks Jennifer 
October 14th, 2003 at 2:19 am
If you are running PHP with Microsoft IIS Go to Internet Information Service MMC snapin, Right click on Default Website, Properties, Documents Tab, add Default.php in the enabled default documents list and move it to the top of the list.
January 10th, 2004 at 3:45 pm
Where is .htaccess found?
Stupid question I know!
January 10th, 2004 at 3:52 pm
It is a file that would be found (or can be placed) inside any directory on your server. If you’re using an FTP client to look for it - make sure that it will even SHOW YOU those files. Some FTP clients have a special setting that you need to change in order for it to display files that begin with a “.” - To be honest - in any FTP application I’ve ever had - I’ve NEVER been able to find that setting!! I usually use my host provider’s “file manager” through “cpanel” to navigate to and edit those files.
May 5th, 2004 at 1:44 pm
just a slight modification to this comment I left here - I believe that if a sub directory below where you have your .htaccess file is accessed via an alternate URL (ie a different URL/domain that points specically to that SUBDIRECTORY) - then the settings in that outside .htaccess WILL NOT affect those pages! I’m not sure if the same occurs when the it’s a SUBDOMAIN - as opposed - ie. subdomain.maindomain.com
October 19th, 2004 at 4:39 pm
October 21st, 2004 at 2:33 am
I know I’m replying to a rather old post, but since FTP clients have driven me nuts with their inability to show “.” files I thought I’d mention my FTP Client of choice (which has the setting you refer to). FileZilla! It’s great. Check it out.