![]() |
![]() |
Home / What is mod_perl? / | ![]() |
![]() |
![]() |
||||
![]() |
![]() |
|||
![]() |
![]() |
|||
![]() |
||||
![]() |
![]() ![]() ![]() |
![]() |
||
![]() |
Example PerlTransHandler | ![]() |
||
![]() |
||||
![]() |
![]() |
![]() |
||
![]() |
||||
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
||
![]() |
||
![]() |
||
![]() |
||
![]() |
||
![]() |
||
![]() |
||
|
||
![]() |
Anyone that's looked at web logs will quickly see the usefulness of this little mod_perl script. It catches all requests for favicon.ico and rewrites the request to point to a valid location. No more logs full of 404 errors.
This example is adapted from the mod_perl Developer's Cookbook, chapter 12.
file:Cookbook/Favicon.pm ------------------------ package Cookbook::Favicon; use Apache::Constants qw(DECLINED); use strict; sub handler { my $r = shift; $r->uri('/images/favicon.ico') if $r->uri =~ m!/favicon\.ico$! return DECLINED; } 1;
And configure in httpd.conf with:
PerlModule Cookbook::Favicon PerlTransHandler Cookbook::Favicon
Although this example could easily be accomplished with Apache's
mod_rewrite
module, this example demonstrates how easy it is to
rewrite URLs programatically, using Perl.
|
![]() |
![]() ![]() ![]() |