Forum Moderators: phranque

Message Too Old, No Replies

Apache handlers don't work on php5

         

jake66

4:24 am on Jan 14, 2008 (gmt 0)

10+ Year Member



Last night I upgraded my VPS to php and mysql 5.

I had a handler in .htaccess so I can parse .txt files as php

It doesn't work anymore. When I head to my .txt files I can now see all of the php code.

AddHandler application/x-httpd-php .txt

<Files directory>
SetHandler application/x-httpd-php
</Files>


Is there a change I have to implement to get it working again?

jdMorgan

5:27 am on Jan 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's an odd mixture of a handler invocation with a MIME-type given as the handler.

Normally, you'd use
AddHandler server-parsed .txt
or some such, while
application/x-httpd-php
would be used in an AddType directive to set the MIME-type of content delivered from files.

PHP's 'hooks' into Apache were kind of kludged-in, and all sorts of odd things 'work' that should not work. As a result, I defer to the folks who use PHP a lot more than I do over in the PHP forum... :)

Jim

Marcia

7:49 am on Jan 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I moved a site to a different host who has PHP5 rather than PHP4 as before and the file handler I use on all other sites to parse html files as php absolutely would not work, I had to play for a while to get it to.

I generally use a few lines (guess they're multi-useful) and they always work, on a few different servers, but I had to whittle it down to this for the one using PHP5

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

Works fine, but it took a bit of fiddling with to find what would.

jake66

1:00 pm on Jan 14, 2008 (gmt 0)

10+ Year Member



Thanks to you both, I tried jdMorgan's bit first, but it ended with the same result (php script showing as text)

and then I tried Marcia's:
which resulted in me getting a popup window asking if I should open in notepad. Did I maybe write this incorrectly?
this is what I used for Marcia's try:

in .htaccess:

AddType application/x-httpd-php .txt .php

jdMorgan

2:26 pm on Jan 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Again, you'll probably get better results asking about PHP in the PHP forum... :)

(There's even a "PHP setup and configuration" mini-tutorial in the library over there.)

Jim

jake66

9:56 am on Jan 16, 2008 (gmt 0)

10+ Year Member



I thought because this was an htaccess issue I should post over here, but I will try the php forum. :)

Marcia

10:20 am on Jan 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<deleted to post in other thread>

[edited by: Marcia at 10:25 am (utc) on Jan. 16, 2008]

coopster

1:50 pm on Jan 16, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



PHP's 'hooks' into Apache were kind of kludged-in, and all sorts of odd things 'work' that should not work. As a result, I defer to the folks who use PHP a lot more than I do over in the PHP forum...

"Kludge" is a good word, I agree as do the folks at Apache. We've been down this road many times. Early on I did my fair share of investigation and still refer to this thread quite often:

[webmasterworld.com...]