Location regex issue.

Igor Sysoev is at rambler-co.ru
Mon Feb 11 13:18:50 MSK 2008


On Mon, Feb 11, 2008 at 12:04:35PM +0200, Athan Dimoy wrote:

> I have a problem with regex in a location used to deny access to some 
> Drupal directories and files.
> 
> location ~ 
> \.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$ 
> {
>    return 404;
> }
> 
> First part up to OR operator (|) works fine but seems to ignore the ^ 
> operator (right next to |).
> 
> Trying to isolate the problem I used the following
> 
> location ~ ^code-style\.pl$ {
>    return 404;
> }
> 
> Unfortunately code-style.pl was still accessible. Is ^ (begin of) operatior 
> supported in location context?

What begin are you mean ? Begin of URI or begin of level in directory ?
"^" is begin of all text. All URIs started from '/'.

You probably need

location ~ /code-style\.pl$ {


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list