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
0
votes
2 answers

Apache mod_rewrite and RewriteMap usage

Options +FollowSymLinks RewriteEngine On RewriteMap name2id txt:/path/to/map.txt RewriteRule ^/mods/([^/]+)\.html$ /mod.php?id=${name2id:$1|0} [QSA,L] First time to make a URL rewriting with rewriteMap. I have a code above but it returns a 404…
christian
  • 153
  • 2
  • 13
0
votes
2 answers

apache mod_rewritemap virtual host file

Hi I am very new to all these. my website need rewrite url. I joined godaddy linux based. i want to use the rewrite map function. and trying to write the syntex for this purpose However i just found that the code has to be put in virtual host file…
TSE KL
  • 1
0
votes
1 answer

URL rewritemap apache

I am pretty new to programming, and have encountered the following problem. Please kindly advise me. I have a website with a URL like www.mysite.com/products.php?cid=3 where the value of the parameter cid (3 here) is generated from a backend…
TSE KL
  • 1
-1
votes
1 answer

Can I use RewriteMap on shared hosting Apache server?

I know that RewriteMap must be defined first before it can be used in .htaccess file. But I am not sure if I can do that in shared hosting or not. Is there any way to do it myself on the server? What I want to do is redirect URL with uppercase to…
iiR
  • 707
  • 1
  • 6
  • 21
-1
votes
1 answer

Multiple values RewriteMap prg

I'm not able to pass multiple values through a RewriteMap prg. This is what I have: RewriteMap encrypt "prg:/bin/python2.7 /var/www/encrypt.py" RewriteRule /secure ${encrypt:%{LA-U:ENV:email}} [P] I am able to pass just one variable from the…
leo
  • 145
  • 1
  • 3
-1
votes
1 answer

Mod_rewrite based on IP and use linked folder name

I want to use .htaccess to rewrite to a folder based on the visitors IP-address. I have a list of IP-addresses with associated usernames (in a text file). The usernames are also the folder names. 192.168.0.2 - John 192.168.0.3 - Ben Example: when…
Maurice
  • 278
  • 3
  • 10
1 2 3 4 5
6