Custom php handler using Apache's mod_actions

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi folks,

i have a problem using a PHP script as a custom handler in Apache.
What i wanna do is this:

Whenever a .html file is requested by a browser, i want Apache to call a
CGI that outputs a header, then the requested file and then a footer.
I want to use PHP for this, as i also want to do some template parsing.

Well, basically, this can be done using Apache's mod_action module,
where a custom handler can be defined for a certain filetype.
This does work correctly. If i request a .html file, the handler is

The strange thing is this: PHP does not output anything but the html header!

This is my custom handler file:
/usr/bin/php-cgi test.php

You see, php-cgi is called to execute test.php, which looks like this:


So, what i would expect is, that the PHP info page is being sent to the
browser, which is not the case. All that is sent back is the .html file
i requested. And the strange thing is: If i execute the CGI from
commandline, i get all the phpinfo output! It just doesn't work when
called by apache!

You might think that the handler is not activated at all, but it is,
because if i change something in the custom handler config, like
spelling the filename wrong, i get a server error.

Also, i tried this using php-cgi directly, like this:

Which just gives me back the exact same results (just the requested
..html file).

Now for the funny part:
I also tried to do this using bash commands, like this:
echo "Content-Type: text/html"
echo ""
echo "Hello World"

This one works!! Hello world is being sent to the browser!

I am quite desperate, don't know what's left to try. Any ideas?
By the way, i'm using Apache 2.0.40 and PHP 3.3.8.

Thanks in Advance,


Re: Custom php handler using Apache's mod_actions

Hi again,

Quoted text here. Click to load it
4.3.8 that is, as you might have figured out already ;)



Re: Custom php handler using Apache's mod_actions

Quoted text here. Click to load it

Does it have to be a cgi that calls a PHP file? Can it just call a PHP file
If so, you can use the directives:


for the header and footer respectively --

Wil Moore III, MCP | Integrations Specialist

Site Timeline