Hi all,
I'm trying to force apache to ask mysql for each url. I use perl script, which accesses the database and depending on the DB querry returns: /index1.php?id=[DB_ROW] or /index2.php?... etc. mod_rewrite sends the querry and the perl script recives it properly, but for some reason it can't do mutch - even if {} else {} blocks don't actually work. expressions like "print '/blahblah/' . $uri . '/newblahblah/'" are printed in the rewrite.log like '/newblahblah/$uri' or even more interesting '/newblahblah/blahblah/$uri' ( $uri is ofcourse the correct string replaced. ) The most "complex" expression that I managed to get working is something like s/^\//%/; s/$/%/;
my httpd.conf without some RewriteCond has in it's <VirtualHost>:
RewriteEngine On
RewriteLog /var/log/rewrite.log
RewriteLogLevel 9
RewriteMap iwct prg:/usr/local/etc/apache2/mod_rewrite.pl
RewriteRule (.*) ${iwct:$1} [PT]
My Perl script is allmost this:
$| = 1;
while (<STDIN>){
$uri=$_;
s/^\//%/;
s/$/%/;
$string=$_;
$sthi->execute($string) or die "$DBI::errstr\n";
$index=$sthi->fetchrow_array();
$sthp->execute($string, $string) or die "$DBI::errstr\n";
$page=$sthp->fetchrow_array();
if ($index){
print '/index.php?source='.$index;
}
else {
if ($page){
print '/page.php?id='.$page;
}
else {
print $uri;
}
}
}
$sthi and $sthp are defined at the beginning of the script.
It works perfectly when started from the console, but not from within mod_rewrite.
I can't find where should the perl script output any errors too ...
Thanks for any help in advance.
P.S. Sorry for the bad englesh.
P.S.2: How does mod_rewrite work with DBM files ? Do I have to restart apache each time I update my DBM file ?