while i request files http://domain.com/config.xml or http://domain.com/include/config.xml both files downloaded, which is not good,
simple ~* /\.(tpl|xml)$ {return 404;} works perfect but blocks files everywhere. On Sat, Dec 3, 2016 at 2:07 PM, Francis Daly <fran...@daoine.org> wrote: > On Sat, Dec 03, 2016 at 12:19:44PM +0000, Musta Fa wrote: > > Hi there, > > > im trying to create some regex just to match before second slash and > only. > > and allow all subfolders: > > > > location ~ ^/([^/])+\.(tpl|xml)$ { return 404; } > > > > these files are located in root folder, and i dont want them to be > > downloaded, > > but other files in subfolder are downloadable. > > > > not sure why it not working? > > Why do you think it is not working? > > What request do you make that you want to match this location, but it > does not? > > What request do you make that you want not to match this location, > but it does? > > Test: > > == > server { > listen 8888; > location ~ ^/([^/])+\.(tpl|xml)$ { return 200 "Did match: $uri\n"; } > location / { return 200 "Did not match: $uri\n"; } > } > == > > $ curl http://127.0.0.1:8888/abc.xml > Did match: /abc.xml > $ curl http://127.0.0.1:8888/abc/def.xml > Did not match: /abc/def.xml > $ curl http://127.0.0.1:8888/abc.txt > Did not match: /abc.txt > > f > -- > Francis Daly fran...@daoine.org > > _______________________________________________ > nginx mailing list > nginx@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx >
_______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx