How to use Nginx to restrict access to everyfiles to, except the php files in /

carlg nginx-forum at
Thu Nov 13 08:33:03 UTC 2014


It works, but i am still able to access the php files inside the restricted
directories.  I tried with :

location /myfolder/(.+)\.php$ {
deny all;

But this doesn't work!

Also, i cannot make this method work nice with our clean url's.  We are
using : 

location / {
		#try_files $uri $uri/ /index.php;
		#try_files $uri/ $uri /index.php?$query_string;
                include /etc/nginx/naxsi.rules;
                try_files $uri $uri.html $uri/ @extensionless-php;


	location @extensionless-php {
    		rewrite ^(.*)$ $1.php last;
	allow all;	

thank you in advance for your help,


Posted at Nginx Forum:,254785,254799#msg-254799

More information about the nginx mailing list