sub handler { my $r = shift; my $req = Apache2::Request->new($r); my $mech = WWW::Mechanize->new( agent => 'Mozilla/5.0', autocheck => 1, ); $mech->cookie_jar(HTTP::Cookies->new); my $domain = 'http://somesite.org'; my $uri = $req->param('uri'); if(defined $uri){ $mech->get($domain); }else{ my $args = $r->unparsed_uri(); my $base = "$domain$args"; $mech->get($base); } my $response = $mech->response(); my $html = $response->content; $r->content_type($mech->content_type); $r->content_encoding($response->content_encoding); print $html; return Apache2::Const::OK; }