Forum Moderators: phranque

Message Too Old, No Replies

.htaccess handler works for html files but not php files

Action myhandler /test.html works

         

carsongarden

6:06 am on Jan 30, 2006 (gmt 0)

10+ Year Member



Hi,

I'm stumped by this. Any help would be appreciated.

The following .htaccess file works fine on my localhost:

AddHandler myhandler .html
Action myhandler /test.php

-When I upload it to an ISP, it doesn't work: I get a "page not found" error (the ISP's default 404 page).

Oddly, if I change the second line to:

Action myhandler /test.html

Then it works, bringing up the test.html page. Both test.php and test.html are definitely in the same folder.

Is it possible the path for a PHP file is figured differently, or is there some Apache setting regarding running the PHP code? I did check, and the code in test.php runs fine when I path to it directly.

Thanks for your help!

extras

2:56 pm on Jan 30, 2006 (gmt 0)

10+ Year Member



Action directive requires CGI script/program.
If you want to use PHP, you should rename it with .cgi extension,
and add shebang line at the top.

Example:
#!/usr/local/bin/php

Note:
You need to check actual path to the correct PHP executable and use that path.

For more info, please read Apache documents.

jdMorgan

3:09 pm on Jan 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might have better luck with:

AddHandler server-parsed .html
AddType text/html .php

instead of the directives you show.

See Apache mod_mime [httpd.apache.org].

There's also the possibility that the server is misconfigured if it's Apache 1.x, with the LoadModule list order being incorrect. We'll discuss that if the above doesn't help.

Jim