Refuse to download non-php files

34 views Asked by At

I want my server to refuse to view and download all non-php files, So i wrote this code in "nginx.conf":

enter image description here

I restarted the server, did some testing, and found that it didn't work. Where is the mistake, please?

1

There are 1 answers

0
Tarun Lalwani On BEST ANSWER

Instead of using a negate block you can use something like below

server {
    listen 80;

    location / {
        deny all;
    }

    location ~ \.php$ {
        fastcgi_pass ...;
        ....;
    }
}