Welcome to WebmasterWorld Guest from 126.96.36.199
When I try this on my server, however, it doesn't work (although it works fine if I rename the file to something.php instead of something.htm)
I would rather use .htm extension though, as I think it's better for search engines and I don't care to notify folks that I'm doing anything dynamic in the background by having the php extension.
I was able to get this to work by modifying my .htaccess file to add a line as follows:
AddType application/x-httpd-php .php .php3 .phtml .html .htm
So I guess my real questions are:
1) Is it normally necessary to add this line to your .htaccess file in order to process PHP in .htm files?
2) Is there any reason NOT to add this line to my .htaccess file? In other words, is there any reason (performance, security, whatever..) why I wouldn't want my server to process .htm files with PHP code in them?
As I mentioned, I'm just getting started with this so forgive me if the question seems a bit inane..
Thanks for any help that can be provided :)
You need to tell the server which files to run through the PHP engine, and that is the way you do it.
> Is there any reason NOT to add this line to my .htaccess file
You'll take a performance hit on non-PHP .htm pages as they'll still be parsed for PHP coding. If most of your pages are straight HTML then you'd probably be better off putting your PHP pages in a seperate directory and only putting the .htaccess file in there.
If all your current pages are .htm then you could just add
AddType application/x-httpd-php .php .php3 .phtml .html
And then just rename the pages containing the PHP to .html That way, the non-php pages won't get parsed.