Forum Moderators: phranque

Message Too Old, No Replies

Trouble enabling PHP for .html files in .htaccess.

         

Linda_A

9:45 am on Jun 23, 2004 (gmt 0)

10+ Year Member



Hello,

I am trying to enable PHP in .html files with the following directive in my .htaccess:

AddType application/x-httpd-php4 .html .php

But when I change from .php to .html on a test page I have prepared, the php in said page stops working.

I have contacted my host and she has said that AllowOverride All and Options All is set, and so I should be allowed to make this change in my .htaccess. She has also confirmied that the directive she uses in httpd.conf is application/x-httpd-php4, not application/x-httpd-php.

Is there anything else that is required for this kind of override to be allowed in .htaccess?

Duke_of_Url

9:53 am on Jun 23, 2004 (gmt 0)

10+ Year Member



Hi

I have this in my .htaccess

AddType x-mapp-php4 .php
AddType x-mapp-php4 .htm

Seems to allow php to run in my .htm files, I got this from someone I know as I'm not too hot on this kind of thing :-)

hth
DoU

Linda_A

10:07 am on Jun 23, 2004 (gmt 0)

10+ Year Member



Hmm, I'll give it a try, although I know my host uses the application/x-httpd-php4 directive in httpd.conf, so I think it might conflict to have a different directive.

WhosAWhata

7:32 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



AddHandler php-script .php .htm .html
AddType text/html .php .htm .html

Linda_A

8:03 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



Isn't AddHandler php-script only for when PHP is run as a CGI process?

Linda_A

10:31 am on Jun 24, 2004 (gmt 0)

10+ Year Member



I have tried both AddType x-mapp-php4 and AddHandler php-script, and neither works. The first results in Netscape not recognizing the file, the second does nothing.

Could it be that AddType application/x-httpd-php4 is the correct directive to use, but that my host is missing some configuration directive beyond AllowOverride All and Options All?

jdMorgan

3:08 pm on Jun 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> The first results in Netscape not recognizing the file, the second does nothing.

You might want to check the MIME-type in the server response header; Non-IE browsers need the MIME-type to be correct. Try the Server Header [webmasterworld.com] checker tool to examine the response header for your page request.

This may or may not be helpful, but if the MIME-type is wrong, that may provide a clue to someone who's seen this problem before [google.com] and can help.

Jim

Linda_A

2:30 pm on Jun 25, 2004 (gmt 0)

10+ Year Member



The Content-type is specified as text/html (I do this in .htaccess), and the header checker tool does report it as such.

Very odd.

Linda_A

2:03 pm on Jun 26, 2004 (gmt 0)

10+ Year Member



I decided to try:

<Files *.html>
AcceptPathInfo on
SetOutputFilter PHP
SetInputFilter PHP
</Files>

This does work. However, since no one has recommended it, I have to wonder if this is a bad solution for some reason or other? :)