Forum Moderators: coopster

Message Too Old, No Replies

Php and html and htaccess ... again

php, html, htaccess AddType application/x-httpd-php

         

kwasher

8:09 am on Oct 11, 2003 (gmt 0)

10+ Year Member



php newbie here

AddType application/x-httpd-php .php .php3 .phtml .html .htm

I added an .htaccess file with the above statement in it, to a directory.

This directory contains my header.php file, which I have now renamed to header.html.

I thought it would parse header.html containing php code and come out alright.

Mozilla tells me it doesnt know how to handle it. What did I screw up?

MonkeeSage

9:13 am on Oct 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The default mime magic for the html extension may be taking precedence over your .htaccess, in which case you could try using the
ForceType
directive instead of
AddType
.

It could also be because the server doesn't allow .htaccess changes for that directory. Or it could be a Mozilla issue. Can't do much in those cases.

Not sure what else might cause the problem.

Sort of OT, but is worth mentioning...you probably don't want to set the mimetype for the html extension to be processed by PHP for a couple reasons: PHP may throw errors for regular HTML documents (e.g., the <?xml...?> declaration will throw PHP for a loop); and your server overhead will be much higher since every html document served -- PHP or not -- will be passed through the PHP interpreter.

Jordan

kwasher

4:56 pm on Oct 11, 2003 (gmt 0)

10+ Year Member



Thanks Jordan!

you probably don't want to set the mimetype for the html extension to be processed by PHP

Yes. I don't really want to.... I have a pearl/cgi script that wants me to put an HTML header and footer on it (it lets me set the path to the header and footer) but I want to use my php header and footer, and trying to figure out a way to do that.

I've been searching message forums and php org for 3 days now....

If you have a thought on this I am certainly listening!

jatar_k

5:47 pm on Oct 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



there is no real hit by making html extensions get parsed by php. Most of us have always done it that way and haven't had any problems.

did you read this thread as well?
does a php "include" command work in a html file? [webmasterworld.com]

AddHandler could also be the problem

MonkeeSage

6:16 pm on Oct 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My bad, I was making an assumption about the server overhead, never actually tried it. PHP is so slick I just should have known better! ;)

Jordan