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 francis at daoine.org