Marcus Clyne
October 27, 2009 09:00PM
Mathew Davies wrote:
> Hi.
>
> I am having trouble with a location regular expression.
>
> location ~* ^/(library|conf|appg) {
> return 403;
> }
>
A more efficient way of doing this is :

location ^~ /library {
return 403;
}

location ^~ /conf {
return 403;
}

location ^~ /appg {
return 403;
}

since it checks the URLs using string comparison (rather than regexes)
and will halt location-searching immediately if it matches one of the
above locations.


>
> It is my understanding the following regular expression should match
> any uri starting with library, conf or appg. However, this is not the
> case.
>
> For instance.
>
> http://domain.com/appg/
>
>
> will match fine where as
>
> http://domain.com/appg/.file
>
>
> wont match (causing the file to be downloaded)
>
> Am I doing something inherently wrong or is this a bug in Nginx?
There's probably some other location directive in your conf that is
matching http://domain.com/appg/.file. If you don't want to use the
more efficient, static locations above, try posting your full conf file.

Marcus.
Subject Author Posted

Location regex

Mathew Davies October 27, 2009 08:30PM

Re: Location regex

Marcus Clyne October 27, 2009 09:00PM

Re: Location regex

Mathew Davies October 27, 2009 09:44PM

Re: Location regex

Marcus Clyne October 27, 2009 11:02PM

Re: Location regex

Michal Kowalski October 27, 2009 11:02PM

Re: Location regex

Igor Sysoev October 28, 2009 03:34AM

Re: Location regex

Mathew Davies October 28, 2009 10:56AM

Re: location regex

Igor Sysoev November 01, 2016 10:06AM

Re: location regex

olat November 01, 2016 06:49PM

Re: location regex

Igor Sysoev November 02, 2016 07:30AM

Re: location regex

Francis Daly November 03, 2016 02:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 198
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready