How to deny access to a folder, but allow access to every subfolders (wildcard)

Raúl Galicia lvqp at sahsanu.com
Fri Jan 9 01:25:10 UTC 2015


El 2015-01-09 01:44, carlg escribió:
> Hi,
> 
> I need to deny access to /members but allow access to every folders 
> below.
> 
> There may be a lot of folders, maybe a thousan, and each of those 
> folders
> contain 5 other folders.  So i need a wildcard.
> 
> Here is what i tried :
> 
> location ~ ^/members/([^/]+)/([^/?]+)$ { allow all; }            #allow
> every folders below /members with wildcard
> location ~ ^/members/ { deny all; }                                    
> #deny
> everything else
> 
> But it doesn't work.


Hi,

This works for me... or I think so ;)

location ~* /members/.+/.* { allow all; }
location ~* /members/.* { deny all; }

Cheers,
Raúl Galicia



More information about the nginx mailing list