0

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 pair. When the RewriteCond matchs then the value of the key will be added to the rewritten URL.

That all works fine but now I want to add a default value into the substitution of the RewriteRule in case the RewriteMap cannot find the key in the RewriteMap file. The syntax in the RewriteRule looks like ${ MapName : LookupKey | DefaultValue }. When the Look-up-Key will not be found the DefaultValue will be used instead.

What I exactly want is that when the key is not found the original request URL will be used and no substitution will be conducted.

My first approaches were to use ${MapName:$1|http://%{HTTP_HOST}%{REQUEST_URI}?{QUERY_STRING}} or ${MapName:$1|http://%{HTTP_HOST}%{REQUEST_URI}} but none of it works. I don't know what to put as a DefaultValue after the |.

JakobT
  • 11
  • 2

1 Answers1

1

I just found a solution for my problem. It is necessary to define a RewriteCond that checks if the correct key is in the RewriteMap file. If it is not in the map file the RewriteRule will be scipt and the original request URL will be used.

The RewriteCond looks like RewriteCond ${MapName:$1|NOT_FOUND} !NOT_FOUND .

JakobT
  • 11
  • 2