Condition with map

Discuss practical ways rearrange URLs using mod_rewrite.

Condition with map

Postby summer » Tue Jan 06, 2004 3:08 pm

I'm trying to write a rule that says if you can't find a file by the name of the URI then look it up in the rewrite map. but it's not working. Here's what I have so far:

RewriteMap products txt:/data/www/root/htaccess.txt

RewriteCond !/{REQUEST_URI} -f [NC]
RewriteRule /(.*)$ /products/detail.php?ProductID=${products:$1} [L]

Any ideas? the condition worked fine when I applied a moer simple rule to it like this:

RewriteCond !/{REQUEST_URI} -f [NC]
RewriteRule /(.*)$ /filenotnoud.html [L]

thanks
summer
summer
 

Postby iiinetworks » Tue Jan 06, 2004 8:07 pm

You may want to change the [L] to [L,R]. Then you will be able to see what it's doing. You can always change it back after you get things working.

I tried using a rewrite map at one point. What I found was that it worked better to rewrite the PHP file so that it would process the URI. E.g.
Code: Select all
RewriteRule /(.*)$ /products/detail.php?URI=$1 [L,R]
Inside, you would use something of form
Code: Select all
/* Lookup map from URI to ProductID */
$_GET['ProductID'] = /* whatever */;
to get the same effect. Replace parts in /* */ appropriately.

Hth,
Matt
iiinetworks
 
Posts: 8
Joined: Sat Oct 11, 2003 11:53 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 39 guests

cron