0

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

<VirtualHost *:80>
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}
</VirtualHost>
Yasser
  • 5

1 Answers1

1

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:

<?php print_r($_GET); ?>

And this is what I get:

$ curl 'http://localhost/beta/category/electronics'
Array
(
    [cat] => 1
)
Renan
  • 366