maard has asked for the wisdom of the Perl Monks concerning the following question:

Hello, brothers in faith!

I have apache2 with mod_perl/mod_php and some php software running on it. And I want to filter request headers for php scripts and filter its output again (both headers and body). php scripts are located under /php_area. The problem is, that if I write

<Location /php_area> SetHandler modperl PerlInputFilterHandler My::PHPInputFilter PerlOutputFilterHandler My::PHPOutputFilter </Location>
then php scripts stop being processed by mod_php and instead are output as plain php code.

For now I solved the problem by writing "proxy" response handler, which uses LWP to perform requests to php and give user back what I want (it's much simpler than fix all that php code), but i'm still interested in using filters - is it possible in this situation ?

Replies are listed 'Best First'.
Re: surround PHP with filters
by pileofrogs (Priest) on Dec 30, 2005 at 17:23 UTC
Re: surround PHP with filters
by perrin (Chancellor) on Dec 29, 2005 at 19:53 UTC
    Yes, it is possible to do what you show in your sample here. The "SetHandler modperl" looks wrong to me, but the concept is correct. Did you actually write code for these filters?
      That SetHandler directive isn't wrong, see example in mod_perl2 filters. But I overlooked something obvious: use of <Files ~ "\.php"> instead of <Location>