[Melbourne-pm] Apache2::Filter::RE

Scott Penrose scottp at dd.com.au
Sun Feb 10 16:06:11 PST 2008

I am really sorry I have confused everyone.

This has NOTHING to do with URLs - so mod_rewrite - right out.

I will give you a new example, just to save some confusion.

s/Scott /Scooter /g

It is a content filter, not a URL/Header filter.

As for chaning on disk - just not practical. If that was the case we  
wouldn't have any apache filters - we could get rid of Deflate for  
example :-)

Content these days comes from remote sources, dynamic generated, etc
And we want to change things on the fly... filters are a way of doing  

Anyway, the answer is... Apache::StrReplace with some modifications  
(actually I had already written my own but the code is 90% the same) -  
i.e. a set of Regular Expressions. I have contacted the author to see  
if we can make some changes, if not I will release my own module.

Sorry that the URL example I gave confused - I was changing URLs in  
the content - not URLs received by Apache. So my RegEx above should be  
more clear.

What I was/am looking for is a filter - not another way to do it as I  
know those :-)

BTW. There are other solutions, the plethara of XSL modules do the  
trick - but I thought they would probably be overkill for one simple  
change. Most of the Template filters can do it, you can even compile  
PHP as a filter and run that. All of those seem very heavy weight for  
a simple solution - what I want(ed) was mod_rewrite for content :-)

BTW. There is another problem with mod_rewrite - not related to this  
problem - I wrote Apache::Remote::Simple to get around it. The problem  
is that mod_rewrite can not change Query String or other headers -  
only the URL. In the system I was writting it was necessary to map a  
single search URL with "?q=My+Search+String" into what ever was  
appopriate for the remote system (e.g. http://search.cpan.org/search?query=My+Search+String&mode=all 
  for searching CPAN) - unfortunately it can't do it.


On 11/02/2008, at 10:54 AM, Toby Corkindale wrote:

> Scott Penrose wrote:
>> On 10/02/2008, at 5:24 PM, deepfryed at gmail.com wrote:
>>> mod_ext_filter allows you to do something similar using an external
>>> program, Apache::StrReplace does something very similar with a
>>> perloutputfilterhandler
>> External is too slow for production.
>> Apache::StrReplace only allows a single Reg Ex.
> If performance is an issue, why not fix the problem at the source?
> ie. Edit your HTML on-disk..
> Failing that, I suggest using mod_rewrite or a custom 404 handler. In
> either case, you detect that the URL looks like one that should be on
> the other server, and redirect them over there.
> Lastly, if you're definitely going to filter every page, then I hope
> you're using a reverse-proxy to cache the results?
> -Toby
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm

More information about the Melbourne-pm mailing list