I have the following RewriteMap function:
RewriteMap map_company txt:/var/www/vhost/domain.com/httpdocs/map_company.txt
I am trying to rewrite my index.php?shop_id=1 to /company-name/
so my map_company.txt file contains: company-name 1
I cannot seem to get it working. Here is my htaccess file:
# tried this
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?shop_id=${map_company:$1} [NC,L,QSA]
#and this
RewriteRule ^(\d+)/$ index.php?shop_id=${map_company:$1} [NC,L,QSA]
If I do that then I get the error: File does not exist: /var/www/vhosts/domain.com/httpdocs/company-name
Does anyone have any ideas? I also need to make sure it doesn't affect my standard folders like "css, js, images".
Have you turned on the rewrite engine? RewriteEngine on
needs to be defined. Also, check you have the necessary AllowOverride
value for this folder to let you do this.
As an aside, I'd consider making the trailing slash optional:
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?shop_id=${map_company:$1} [NC,L,QSA]