Questions tagged [rewritemap]

When using `mod_rewrite`, the `RewriteMap` directive defines a "Rewriting Map" which can be used inside rule substitution strings to insert or substitute fields with a key/value lookup.

The RewriteMap directive defines a Rewriting Map which can be used inside rule substitution strings by the mapping-functions to insert/substitute fields through a key lookup. The source of this lookup can be of various types.

The MapName is the name of the map and will be used to specify a mapping-function for the substitution strings of a rewriting rule via one of the following constructs:

${ MapName : LookupKey }
${ MapName : LookupKey | DefaultValue }

For example, you might define a RewriteMap and RewriteRule as follows:

RewriteMap examplemap txt:/path/to/file/map.txt
RewriteRule ^/ex/(.*) /ex/index.php?path=${examplemap:$1}

If the map file contains a line reading foo bar, then that rule would rewrite a request for /ex/foo to /ex/index.php?path=bar.

Documentation: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap

81 questions
1
vote
0 answers

Using RewriteMap, RewriteCond and RewriteRule, unable to retrieve default value from the map

I am using apache to redirect user's application from an old server to a new server. This is done based on a user's x-user-id header. I created a RewriteMap which contains x-user-id new url to use mapping. 40951879-077e-41a6-bbab-adbded39550d…
1
vote
2 answers

is restarting apache service needed with any changes to rewritemap file?

I am using a perl script file as a map file in RewriteMap directive. As i read the apache load the script once at the beginning, So is it needed to reload or restart apache after any changes to this script file?
hd.
  • 17,596
  • 46
  • 115
  • 165
1
vote
1 answer

Performance Improvements using RewriteMaps-Text file

What are the ways to improve the performance of URL redirects by using the rewrite Maps. Currently I am using rewrite Map using the lookup keys in a text file. There are 2000 keys in the text file and the number is expected to increase by 100% in…
366x24x7
  • 13
  • 3
1
vote
1 answer

RewriteMap not working at all

I'm trying to get MapRewrite working for some vanity urls but I'm just not having any luck. I don't get errors, it just doesn't seem to work (redirect). Here's the code I put in my vhost.conf: RewriteEngine On RewriteMap vanURL…
Andrew
  • 2,691
  • 6
  • 31
  • 47
1
vote
1 answer

IIS 7.5 URL Rewrite Module - Rewrite Maps with variables

I have several pages on my site that have long and unreadable URLs that I'd like to be able shorten. The problem I'm having is appending query strings with variable values. For example: "www.example.com/dir1/dir2/filename.php" shortens to…
chrisc
  • 166
  • 1
  • 11
1
vote
1 answer

RewriteMap to clean up .htaccess file

Hi I'm not that great at regex and have been tasked with cleaning up a line by line .htaccess file. I've read that RewriteMap is a good alternative to avoid a messy .htaccess file, but I've really got no idea where to start. Most guides seem to…
1
vote
1 answer

Redirecting #Include in IIS

I am working through a massive site I inherited that has a mixture of classic ASP, inline ASP.NET and compiled ASP.NET and all of those utilize #INCLUDE tags in some form. I've been playing with IIS and rewrites/rewrite maps and seem to have found a…
Scott Salyer
  • 2,165
  • 7
  • 45
  • 82
1
vote
0 answers

RewriteMap rnd in .htaccess symfony2

I'm currently trying to do a simple random load balancing using 2 servers with symfony2. In the /web .htaccess file, I have tried a lot of combinations, but result is always blank and I do not see a way to debug. What could help ? .htaccess file…
Nicorr
  • 724
  • 6
  • 22
1
vote
0 answers

Apache RewriteMap not working

I'm trying to rewrite some of my URLs using an apache RewriteMap. I'd like to transform www.mywebsite.com/?p=category&id=xxxx in www.mywebsite.com/category/channel/program/personnality I use the id in a php script to retrieve the necessary…
mb3rnard
  • 397
  • 3
  • 12
1
vote
2 answers

Assistance with a RewriteRule using RewriteMap

I'm fairly new to mod_rewrite and I'm trying to get the RewriteMap directive to work properly. I would appreciate your help in using it. Our URL format is as follows: example.com/section.php?xSec=[ID] So for section 201, which is 'Apple iPads' the…
Daniel Kilburn
  • 167
  • 1
  • 4
  • 13
1
vote
0 answers

mod_rewrite 301 redirect hundreds of old unstructured url

I need to redirect (301) hundreds of old unstructured urls to new ones. Old urls have querystring domain/directories/randomtext?args=1 I have a file with oldurl newurl lines. I am trying with RewriteMap in virtualhost RewriteMap mapfile…
Luis
  • 13
  • 3
1
vote
1 answer

IIS7 and rewriteMap for friendly URL's

I have an external "rewritemaps.config" file with the following entries:
pixelkicks
  • 866
  • 2
  • 11
  • 23
1
vote
1 answer

RewriteLock hangs Apache on re-start when added to an otherwise working Rewrite / Rewritemap

I am on a Network Solutions VPS, four domain names share the IP. I have a Rewrite / RewriteMap set up that works. The Rewrite is in the file for the example.com web address at var/www/vhosts/example.com/conf/vhost.conf, the Rewrite being the only…
kidcobra
  • 23
  • 3
1
vote
1 answer

htaccess to rewrite param=NUMBER into /text

I am trying to figure out how to rewrite URLs from something like this: example.com/collection.php?collection=1 Into: example.com/collection-name.php I recently redesigned an e-commerce site and need to redirect the old URLs to the new ones. I've…
dkmojo
  • 125
  • 5
0
votes
1 answer

Url rewrite in IIS 7.0

i have two seperate config files, which contains url reqwrite tags, i want to point these files to the web.config, under rewrite element, until i have one if i add one more similar tag to point…
Abbas
  • 4,948
  • 31
  • 95
  • 161