A Programmed RewriteMap for mod_rewrite in PHP

Source Code

written in PHP to provide a programmed response for
mod_rewrite. If you want to rewrite URLs that are
stored in a MySQL database, simply add in a
mysql_connect before you enter the loop, and then
do the appropriate query within the loop! */

/* Extra lines to add to httpd.conf:
RewriteEngine On
RewriteMap tryme prg:/home/trainee/website/andy
RewriteRule (.*.htm) ${tryme:$1}

set_time_limit(0); # forever program!
$keyboard = fopen(“php://stdin”,”r”);
while (1) {
$line = trim(fgets($keyboard));
if (preg_match(‘/^(.*).htm$/’,$line,$igot)) {
print “$igot[1].htmln”;
} else {
print “$linen”;


Don’t Stop Here

More To Explore