I am trying to build a simple mod_rewrite map to have category names translated into ids like so: ../category/electronics -> category.php?cat=1
The map is placed inside the www folder. The code ignores the map as if it doesn't exist
This is my rewrite code, what is wrong?
edited: path to catmap.txt, now it's working correctly
DocumentRoot "${path}/www"
....
RewriteMap cat2id txt:${path}/www/catmap.txt
RewriteEngine On
RewriteOptions Inherit
RewriteLogLevel 3
RewriteRule ^/beta/category/(.*) /beta/category.php?cat={cat2id:$1}
Answer
The RewriteRule should be:
RewriteRule ^/beta/category/(.*) /beta/category.php?cat=${cat2id:$1}
I created the file /var/www/beta/category.php
with the following contents:
And this is what I get:
$ curl 'http://localhost/beta/category/electronics'
Array
(
[cat] => 1
)
No comments:
Post a Comment