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
1 answer

apache rewrite map redirect to 404

My Situation: I implemented an apache Rewrite Map to redirect incoming requests based on a database RewriteEngine On RewriteMap dbapp prg:/usr/local/somewhere/dbapp.rb RewriteRule ^/(pattern)$ ${dbapp:$1} [R] So far everything works fine, but I…
dStulle
  • 609
  • 5
  • 24
0
votes
1 answer

Conditionally whitelist IP's in Apache using presence or absence of files

I found a pretty good solution to this problem but it is missing one component that I need. This is close: # WHITELIST IPS # RewriteMap ipslist txt:/path/to/whitelist.txt RewriteCond %{REMOTE_ADDR} ^(.*)$ RewriteCond ${ipslist:%1|black} ^black$…
Pete Helgren
  • 438
  • 1
  • 7
  • 21
0
votes
3 answers

Basic Static-to-Static Rewrite (or Redirect) via htaccess or httpd.conf

We are moving from one site language/CMS (coldfusion/custom) to another (PHP/Drupal) and need to have some of our old pages redirected to new ones. I have access to both the .htaccess and httpd.conf (and apache2.conf) as this is a vps on…
0
votes
1 answer

static url rewrite, using rewrite map is not working

I have a website on azure, and I am trying to make some user-friendly urls to my websites use. I have downloaded IIS remote manager, and did as it was explained here. Although the article is since 2008, the GUI of the remote IIS manager is still…
HS1
  • 608
  • 2
  • 10
  • 28
0
votes
2 answers

Rewrite URL with RewriteMap Error

I have to Rewrite massive number of URLs e.g: FROM: http://www.lespoulettes-bijoux.fr/produit2.asp?id_produit=8489 TO:…
0
votes
1 answer

apache rewritemap using txt file - match fail

I am trying to establish a rewritemap using a simple txt file for a special project that will ultimately contain about 150 redirects. I've read through the other posts here and tried to apply alternate mods, but I just can't make a single redirect…
busy1
  • 23
  • 7
0
votes
1 answer

mod_rewrite causes apache to crash with Rewritemap prg directive

Apache configuration: RewriteEngine on RewriteLock /var/www/lib/rewrite.lock RewriteMap sessionValid prg:/var/www/lib/allow.php I fixed the obvious of setting the file executable, but now it is giving this: [Fri Feb 12 01:55:31 2010] [error] (2)No…
Luke
  • 45
  • 2
  • 5
0
votes
1 answer

301 Redirect w/ 2 GET variables using ReWrite Map

I am trying to 301 redirect based on two GET variables in this URL: http://www.jwsuretybonds.com/surety-bonds/surety_bond.php?bond_form_id=171&bond_type_id=45 I want to redirect it to:…
0
votes
1 answer

apache rewritemap not working URL does not translate

I cannot get my rewrite map to work. I have read a lot of pages on this and yet can't figure out how. I have the following in my httpd.conf and took an apache restart RewriteMap ErrorMap…
Rahul
  • 51
  • 3
0
votes
3 answers

Mod_ReWrite / ReWriteMap a URL using a database lookup script

The Scenario I have completely rewritten an old existing ASP classic ecommerce website over to PHP. The database design of the previous site had alot of relational ID problems causing troublesome linking of product data rows to other tables in the…
ticallian
  • 1,631
  • 7
  • 24
  • 34
0
votes
1 answer

suPHP wont allow access to parent magento multisite via symlinks. is there another way to do this? (example rewrite prg)

ive seen other posts on stackoverflow about this but there hasnt been a solid answer to any of the questions. so im combining the knowledge i've gathered from the other posts and rewording things to hopefully get a solid answer. suPHP is a mod that…
Katushai
  • 1,510
  • 2
  • 14
  • 27
0
votes
3 answers

rewritemap not matching

I'm having trouble with my rewritemap not matching things: RewriteMap map txt:rewritemaps\map.txt [NC] RewriteCond ${map:$1|NOT_FOUND} !NOT_FOUND [NC] RewriteRule ^(.+)$ ${map:$1} [NC, R=301] The map has about 4,500 entries, including: arctic …
Adam Hopkinson
  • 28,281
  • 7
  • 65
  • 99
0
votes
1 answer

.htacces - create a rewritemap that redirect all urls to a standard one

i have to redirect some links to a standard one like: /lang/news1 /lang/news2 /lang/news3 to /lang/news.html Now i don't want to set redirect 301 directly on htaccess (i have 500 links) and i read the possibility to create a rewritemap and a…
0
votes
1 answer

RewriteMap not working for urls with query params

It seems rewritemap is not considering query params in matching url. Please suggest a solution. My setup in httpd.conf file: RewriteMap redirects dbm=db:/usr/local/apache/conf/redirects.db RewriteCond ${redirects:$1} !="" RewriteRule ^(.*)$…
Shatiz
  • 779
  • 1
  • 6
  • 15
0
votes
1 answer

.htaccess 301 redirect for thousands of entries or RewriteMap

I have a site with thousands of pages that need to be redirected. I was thinking of using a 301 redirect in my .htaccess, but I'm just afraid that this will be very inefficient. Would having a .htaccess with thousands of lines (there is no way to…
coopersita
  • 5,011
  • 3
  • 27
  • 48