Home > Article > Backend Development > nginx prohibits running php in the specified directory
nginx prohibits running php in a specified directory. You only need to add a location rule in the server configuration section.
Recommended: "PHP Tutorial"
1. Prohibit a certain directory from executing php
location ~* ^/download/.*\.(php|php5)$ { deny all; }
2. Prohibit multiple directories from executing php
location ~* ^/(download|down)/.*\.(php|php5)$ { deny all; }
Note: It must be written before the php configuration. Here is an example
location ~* ^/(download|down)/.*\.(php|php5)$ { deny all; } location ~ [^/]\.php(/|$) { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; }
The above is the detailed content of nginx prohibits running php in the specified directory. For more information, please follow other related articles on the PHP Chinese website!