You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Todd Finney <tf...@boygenius.com> on 2000/02/22 15:58:01 UTC
confirming a handler's behavior
Hi,
I'm starting to make the jump from ePerl-bristled files to handlers, and
this is my first attempt. I'm trying to redirect all requests containing
a particular referrer value to another location. The setup below appears
to do the job, but I'd just like to get a more experienced set of eyes ( or
two or three... ) on it, to make sure it's not going to do anything strange.
I'm also curious as to whether or not this will have a significant effect
on the performance of the server.
Taking all requests containing the referrer value 'http://www.someurl.com"
and pointing them to the home page, passing all other requests through
unaltered...
In httpd.conf, not inside a <Directory> or <Location> container:
PerlHeaderParserHandler Apache::boy_Redirect
The package:
package Apache::boy_Redirect;
use strict;
use Apache::Constants qw( :common MOVED );
sub handler {
my ( $r ) = shift;
if ( $r->header_in( 'Referer' ) eq 'http://www.someurl.com' ) {
$r->content_type( 'text/html' );
$r->header_out( Location => 'http://www.boygenius.com/' );
return MOVED;
} else {
return OK;
}
}
1;
thanks,
Todd