views:

27

answers:

0

I want to redirect some urls with id = n to id = n + 1000 (where n is a variable). After searching on the internet I found out that I can do this using a prg type RewriteMap directive.

However, I ran into some trouble getting it to work. The code I am using to test using a custom RewriteMap is included below.

This is my test.pl file that I'm using as the map program:

#!/usr/bin/perl
$| = 1; # Turn off buffering
while (<STDIN>) {
    print $_;
}

I've defined the RewriteMap in my virtualhost.conf file:

RewriteMap prp prg:/var/www/mydomain1.com/test.pl

And this is the RewriteRule where I'm using my custom map:

RewriteRule ^Pro-id-([0-9]+).html http://mydomain2.um.ac.ir/papers-${prp:$1}.html [L,R=301]

What I expect this code (test.pl) to do is to return the same id, but it returns null. What is the problem?