Forum Moderators: phranque
I have been trying to modify a mod_perl script, and I am not sure of the syntax to make this print a page off the site...
This script will look for requests for bad filenames (stuff like requests for formmail.pl and other, hacker sorts of exploit hacks) and redirect them to a null server. I do it now with mod_rewrite, and that works fine, I just thought it might be a bit better in mod_perl. My problem is I am not sure of the syntax to make the redirect (the rest of the script works fine.
Here is a snippet of gode:
return OK if $r->uri eq "/robots.txt";
return OK if $r->uri eq "/error/err403.html";
return SERVER_ERROR unless my $sub = get_match_sub($r,$patfile);
return OK if $sub->($agent);
$r->log_reason("Bad Request: $agent ($agent1)",$r->filename);
print "Location: [null.server";...]
The "print: Location line is what needs to be made to work. When run as above, it does not redirect to the null.server... rather, the present server returns a 404. I would want this to not show the redirect to the client, but just hang them up!
thanks!
dave
$r->header_out(Location => 'http://null.server/');
return REDIRECT;
However, I´m afraid that code will not do what you want:
I would want this to not show the redirect to the client, but just hang them up!
A redirect can either be external or internal to the server.
HTTP 1.1 302 Moved Temporarily
Location: [null.server ]
To be HTTP compliant Apache will add a HTML document as the message body.
It is then up to the UA to request that new URI. Most UAs will update the URI in their address bar. The redirect is shown to the client.
Hope this helps.
Andreas