I'm trying to force a URL to point to a new location. For example:

  • site.com/Gites/
  • site.com/gites/

I currently have a "map" set up on the site:

map $uri $is_rewrite {
    default     no_redirect;
    include /home/xxx/conf/web/chambres.com.extra/links.map;

...and inside that file, one of the rules is:

/gites/ https://$http_host;
#/Gites/ https://$http_host;
/french/Gites/ https://$http_host;

If I uncomment the 2nd line, I get an error!

nginx: [emerg] conflicting parameter "/gites/" in /home/xxx/conf/web/chambres.com.extra/links.map:107

When I test it, sure enough, the lowercase one works, but not the uppercase "Gites". How can I make it case insensative?


The nginx map directive is indeed documented as doing case-insensitive string matching.

Strings are matched ignoring the case.

If this is actually a problem in your case (i.e. you need different results for /gites/ and /Gites/) then you can use a regular expression match, which can be either case sensitive or insensitive.

A regular expression should either start from the “~” symbol for a case-sensitive matching, or from the “~*” symbols (1.0.4) for case-insensitive matching.

So you could match instead:

~^/gites/ https://one;
~^/Gites/ https://two;

Keep in mind that regular expressions are only checked if there are no plain string value matches in the map.

If you don't need different results for each string, then you don't need to do anything. One string match will cover all cases.

  • 1
    With regex one needs to remember anchors, because ~/gites/ will match both the first and third example line. So, the regex needs to be like ~^/gites/. – Tero Kilkanen May 13 at 17:10
  • Thanks guys - works like a charm. I thought I tried regexes, but I guess I didn't! – Andrew Newby May 13 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.