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

.htaccess Rewrite URLs - RewriteMap

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…
Drew
  • 6,736
  • 17
  • 64
  • 96
0
votes
1 answer

Problems with RewriteMap MapType dbd

Continuing from another discussion here: MySQL + htaccess mod_rewrite? Where I was asked to start another question. I added this to my httpd.conf file: DBDriver mysql DBDParams "host=*****,user=*****,pass=*****,dbname=*****" RewriteEngine…
HaLo2FrEeEk
  • 586
  • 7
  • 20
0
votes
1 answer

Apache httpd rewrite url based on query string lookup

I need to rewrite URL to direct request to different backend servers based on query parameter, using a text map of (queryparam servername). I have tried the RewriteMap, RewriteRule with a prg: type and a perl script. But the query string is not…
Rookie
  • 1
  • 2
0
votes
1 answer

Reduce redirects with RewriteMap

I have a RewriteMap in a file, and want to handle (ignore) optional trailing slahses. I would like to minimize the number of redirects in the trailing slash case. How do I change the apache-config? Config: ServerName…
FelixHJ
  • 1,071
  • 3
  • 12
  • 26
0
votes
0 answers

How to fix RewriteRule RewriteMap syntax

I am writing a multi-site platform and currently using the following in my virtualhost/.htaccess RewriteMap sitemap "txt:/home/fb/multimapper/map.txt" RewriteCond %{HTTP_HOST} (.*) [NC] RewriteRule (.*)…
woostar
  • 1
  • 1
0
votes
1 answer

Why did my mod_proxy flag stop working in htaccess?

I've created a RewriteMap to handle a large number of domain proxies. My rewrite conditions looks like this: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ -…
HWD
  • 1,547
  • 7
  • 36
  • 72
0
votes
1 answer

How to handle html pages with RewriteMap and Rewrite

I have a rewritemap with below like content - /sub1/sub2/ /content/sub1/sub2.html /sub3/sub4/ /content/sub3/sub4.html /sub5/ /content/sub5.html RewriteMap testuri dbm:conf/extra/testuri.map RewriteCond ${testuri:$1} !="" …
Vishnu
  • 7
  • 1
0
votes
1 answer

Apache cannot detect and rewrite URLs to lowercase

What am I trying to achieve? I want to convert all URL's that are within the /migrate directory (and subdirectories) to lowercase. What have I done? I have migrated my website from DNN to Wordpress. Therefore I have URL's in my posts that reference…
Nanz
  • 179
  • 2
  • 14
0
votes
1 answer

Apache RewriteMap with multiple RewriteCond not working

I'm using a RewriteMap and a rule (using the map) with two RedirectCond RewriteMap lc int:tolower RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(DE|FR|IT|)$ [NC] RewriteCond %{HTTP:Accept-Language} ^(de|it|fr).*$ [NC] RewriteRule ^/$…
Navrattan Yadav
  • 1,993
  • 1
  • 17
  • 22
0
votes
1 answer

Rewrite Rule with Rewrite Map

I got a problem with the creation of rewrite rule which is using a rewrite map in IIS. The goal is to rewrite requests like /Japan/test.html or /Chile/test.html to jp/en/simple-test and cl/en/simple-test. Here is the rewrite rule:
0
votes
1 answer

IIS Redirection 301 of a link for only one domain without affecting the links of other domains

i have two domains which share a similar link for a content that is /games-for-cats. What i want is redirecting the games-for-cats link to another link for FR website for instance but leaving the games-for-cats link untouched for other domain. I am…
0
votes
1 answer

Rewrite map without access to htdocs

I'm on a virtual server so I don't have access to Apache's htdocs; all I have is .htaccess. Is it still possible to do a rewrite map? What kind of workarounds are there?
Pardoner
  • 1,011
  • 4
  • 16
  • 28
0
votes
1 answer

correct Apache RewriteCond and RewriteRule when using RewriteMap?

Im trying to debug an issue with some apache config, but i cant get the apache rewrite to work when using RewriteMap. this is the content inside /etc/apache2/map.txt /21.html /1.html /22.html www.localhost/2.html www.localhost/23.html…
CayoM
  • 19
  • 6
0
votes
1 answer

How to get the original request URL as a default value when a RewriteRule don't match the RewriteMap key?

I'm using the rewrite_mod to rewrite web service requests. If the QUERY_STRING of the request contains a certain parameter then the URL get some additional parameters. This is my Rewrite Condition. I also use a RewriteMap that defines a key-value…
JakobT
  • 11
  • 2
0
votes
1 answer

Remove Query String from the end of the URL after passing through Rewrite Map

I have a list of several hundred URL redirects/rewrites inside of a rewrite map. Most of the URL's contain query strings that match a specific entry in the rewrite map. I found this question on how to pass the query string into the rewrite map. I…
Yamaha32088
  • 4,125
  • 9
  • 46
  • 97