RewriteMap syntax Regex
Posted
by
ienabellamy
on Server Fault
See other posts from Server Fault
or by ienabellamy
Published on 2012-10-31T08:44:52Z
Indexed on
2012/10/31
11:03 UTC
Read the original article
Hit count: 165
in my .htaccess i've tons of directives, with same syntax:
RewriteRule ^(.*)/PRODUCT_1.aspx http://www.site.com/product.php?id_product=2891
RewriteRule ^(.*)/PRODUCT_2.aspx http://www.site.com/product.php?id_product=2896
and everything works. Now, i created a RewriteMap in my because i need to increase velocity (20.000 redirect 301 in htaccess no good), so:
RewriteEngine On
RewriteMap redirects dbm=db:/var/www/html/presta152/prestashop/redirects.db
RewriteCond ${redirects:$1} !=""
RewriteRule ^(.*)$ ${redirects:$1} [redirect=permanent,last]
and my redirects.db is created by redirects.txt, that contains:
/PRODUCT_1.aspx http://www.site.com/product.php?id_product=2891
/PRODUCT_2.aspx http://www.site.com/product.php?id_product=2896
this works if i try to call for example: www.site.com/PRODUCT_1.aspx i'm redirected... but if i try to call www.site.com/everythingpossibileinside/PRODUCT_1.aspx the redirect doesn't work. So, in my .htaccess this rule:
RewriteRule ^(.*)/PRODUCT_1.aspx http://www.site.com/product.php?id_product=2891
works, but in my RewriteMap no. I think i must change this directive:
RewriteRule ^(.*)$ ${redirects:$1} [redirect=permanent,last]
i tried, but unsuccessful. Thanks to all.
© Server Fault or respective owner