Nginx: Multiple PHP sites in sub-directories

By | January 12, 2018

I’ve been pulling my hair out for hours now.

My [statamic CMS] sites are running in subdirectories on a staging server.


I’m using and NGINX conf provided by Statamic:

Which I’ve modified like so:

All is working but…

…when I navigate to I can download the file without restriction!(!!)

The NGINX config line in question is:

location ~ /.(yml|yaml|html) { deny all; }

I’ve tried the following but no luck:

location ~ /(site1|site2|site3)/.+\.(yml|yaml|html) { deny all; }

To be honest I’m a complete n00b at NGINX, and it’s proving much more difficult to use than Apache.

So my question is how do I modify the above statement to restrict access to the .yaml and .html files?




Give this a try. It requires a $ to match end of string.

location ~* (?:\.(?:yml|yaml|html)|~)$ {
    deny all;

Leave a Reply

Your email address will not be published. Required fields are marked *