Page 1 of 1
HTACCESS for PHP processing in HTM files
Posted: Wed Jul 09, 2003 5:05 pm
by RacerX
Does anyone know of the script that allows .htm files to have PHP processing? I know you add something to the .htaccess file...
TIA!!
Posted: Wed Jul 09, 2003 5:08 pm
by qartis
In your httpd.conf, make sure you have
For your specific <directory> only, to keep security up.
Then, in a .htaccess file, put
Code: Select all
AddType application/x-httpd-php .htm
Posted: Wed Jul 09, 2003 5:17 pm
by RacerX
Wow, that was quick. Thanks!
A few clarifications please...
Do you need the # before 'AddType'?
Do you need the . before 'htm'?
The only reason I ask, is I looked at my current .htaccess file and the were using that syntax.
Also, since this server is at a hosting provider, do I have access to the httpd.conf file you referred to? I have no experience with those.
Here is the page I am trying to fix:
http://www.franchiseprospector.com/devz ... ifieds.htm
Your help is greatly appreciated.
Posted: Wed Jul 09, 2003 7:04 pm
by qartis
You'll need to ask your web host whether or not you can use .htaccess files to alter Apache's configuration for your directory (
http://www.franchiseprospector.com/devzone/)
Posted: Wed Jul 09, 2003 10:49 pm
by redJag
>>Do you need the # before 'AddType'?
No, the # is one of the comment out symbols. This would indicate that the line is not being used by Apache.
>>Do you need the . before 'htm'?
Most likely. I haven't actually tested it without the period, I always just put it in. Try it without and find out I guess

Posted: Thu Jul 10, 2003 6:58 am
by cactus
On a performance note, there is a slight performance overhead in implementing this, because you are asking PHP to process .htm files, if there is no PHP in those files (if they are flat) PHP will still be run.
If you do have flat (no PHP) html pages, ensure you use ".html" as the extension to negate the issue.
(My 2p)
Regards,
Posted: Thu Jul 10, 2003 7:32 am
by RacerX
cactus wrote:On a performance note, there is a slight performance overhead in implementing this, because you are asking PHP to process .htm files, if there is no PHP in those files (if they are flat) PHP will still be run.
If you do have flat (no PHP) html pages, ensure you use ".html" as the extension to negate the issue.
(My 2p)
Regards,
Well, even my .htm files would still have SSI processing/includes, so there will be a use for the parsing.
Also, I am trying to set theses pages up so that they do well in search engines and .htm files have a slight advantage over .php (or other extensions).
I will tweak the files today and see what happens.
Thanks again.
Posted: Thu Jul 10, 2003 8:31 am
by RacerX
Here is an even better solution (having no file extensions), but I tried exactly as they had specified, but with no luck. Any suggestions? And yes, I spoke to the server admin and .htaccess config is allowed.
----------------------
Using the .php extension for all your scripts is not necessary, and can be limiting what you can do in the future without breaking links. There are several ways to hide your .php script extension:
(1) Don't hard code file types at all. Don't specify any dots, and most web servers will automatically find your .php, .html, .pdf, .gif or other matching file. This is called canonical URL format:
http://www.xxxxxx.com/page
http://www.xxxxxx.com/directory/
This gives you great flexibility to change your mind in the future.
(2) In an Apache .htaccess file use:
RewriteEngine on
RewriteRule page.html page.php
(3) Force the webserver to interpret ALL .html files as .php:
AddType application/x-httpd-php .php3 .php .html
---------------------