rewrite url in modperl

[email protected]
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
Hello,

I have this modperl handler:

use Apache2::RequestRec ();
use Apache2::Connection ();
use Apache2::RequestUtil ();
use Apache2::ServerUtil ();
use Apache2::Log ();
use Apache2::Request ();

use Apache2::Const -compile => qw(OK FORBIDDEN);

sub handler {

    my $r = shift;
    my $q = Apache2::Request->new($r);
    my $s = Apache2::ServerUtil->server;

    # get customer's ip
    my $ip = $r->connection->remote_ip;

    if ( is_valid_ip($ip) ){
        return Apache2::Const::OK;

    } else {
        $s->log_error("$ip FORBIDDEN");
        return Apache2::Const::FORBIDDEN;
    }
}


which verify the client's IP and return OK if ip is valid, otherwise
return FORBIDDEN.

Now I have to rewrite the requested url to another one, for example,

when customer requests:
http://example.com/path/12345_YWJjZGVmZw.mp4

the handler will remove the string after "_" (includes the "_"
itself), so the url will become:

http://example.com/path/12345.mp4

(because only 12345.mp4 is a real file on the filesystem,
12345_YWJjZGVmZw.mp4 is just virtual.)

How to implement that?

Thanks for your kind helps.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.