NGINX Location Matching Question - Case insensitive matching at the start of a URI

Brad Van Sickle bvs7085 at gmail.com
Thu Dec 5 23:50:28 UTC 2013


Thanks for the quick response!

Looks like that is matching how I intend... however it (of course) 
revealed another issue in my app layer :) But at least the NGINX configs 
seems correct now.

Thanks!



On 12/5/2013 6:40 PM, Jonathan Matthews wrote:
> On 5 December 2013 23:29, Brad Van Sickle <bvs7085 at gmail.com> wrote:
>> Hi,
>>
>> I'm running in a somewhat urgent issue where I have to make a
>> case-insensitive location match on a URI segment that is at the
>> beginning of the URI.
>>
>> so I want to match
>>
>> /uri-segment/*
>> /URI-segment/*
>> /Uri-Segment/*
>> etc..
>>
>> I know that this will match the start of the URI:
>> location ^~ /uri-segment
> It will, but that's not what the regex-alike "^" means there. There,
> it means "... and if this /does/ match, stop immediately and don't
> consider any regex matches". See
> http://wiki.nginx.org/HttpCoreModule#location for more information. (I
> personally consider this a really bad choice of character by nginx -
> it /always/ confuses me!)
>
>> and this will match regardless of case:
>> location ~* /uri-segment(.*)
>>
>> But chaining them together and using ^~*doesn't seem to work.  Is this
>> possible?  If so what am I missing?
> Seeing how you said this is urgent, I'll not do what I /normally/ do
> and just give you pointers to the docs that'll help you :-)
>
> You want
>
> location ~* ^/uri-segment(.*) { }
>
> HTH,
> Jonathan
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx



More information about the nginx mailing list