[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: set request params
From:       "Jeff Pang" <rwwebs () gmail ! com>
Date:       2007-09-29 3:42:44
Message-ID: ddb1c4550709282042o392919e4t5a302571ea7352c7 () mail ! gmail ! com
[Download RAW message or body]

2007/9/28, martin@kiritsov.com <martin@kiritsov.com>:
> as i see there is no way to set request parameter in mod_perl2

You can rewrite an url using mp2's PerlTransHandler.
This is the sample code from book mp2 user's guide.

If the URI:
http://example.com/news/20021031/09/index.html
is now handled by:
http://example.com/perl/news.pl?date=20021031;id=09;page=index.html
the following handler can rewrite the URI in a way transparent to news.pl,
so you can still use the former URI mapping:
#file:MyApache2/RewriteURI.pm
#---------------------------
package MyApache2::RewriteURI;
use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::Const -compile => qw(DECLINED);
sub handler {
my $r = shift;
my ($date, $id, $page) = $r->uri =~ m|^/news/(\d+)/(\d+)/(.*)|;
$r->uri("/perl/news.pl");
$r->args("date=$date;id=$id;page=$page");
return Apache2::Const::DECLINED;
}
1;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic