Hi,
I've been using mod_rewrite and text based RewriteMaps for quite some time now to perform a variety of tasks on my Apache webserver. However, now i'd like to move away from text based maps which need to be manually updated to php based ones that can automate the process.
I have included an example scenario which i've been using to test this below.
My original map was:
RewriteMap test_map txt:c:/www-apache/map_lookup.txt
Which contained the single line:
localhost 55
Which was working fine. I've now changed it to:
RewriteMap test_map prg:c:/www-apache/map_lookup.php
And the contents of map_lookup.php are:
<?php
$stdout = fopen('php://stdout', 'w');
fwrite($stdout, "localhost 55");
fclose($stdout);
?>
My .htaccess file looks like this:
RewriteEngine on
RewriteRule ^search/([a-z0-9]*)/([a-z0-9]*)/$ /query\.php?item1=$1&item2=$2 [env=BRAND_ID:${test_map:%{HTTP_HOST}}]
And the contents of "query.php" is:
echo '<pre>';
print_r($_SERVER['REDIRECT_BRAND_ID']);
echo '</pre>';
Now, when I run this through using the .txt map, I get the text "55" output onto the screen by query.php. However, when I run it with the .php map - I get nothing.
I've also tried changing the fwrite to the stdout to a simple echo "localhost 55" but to no avail.
Anyone got any ideas?