nginx prohibits running php in the specified directory

藏色散人
Release: 2023-04-07 21:48:02
forward
2489 people have browsed it

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;
}
Copy after login

2. Prohibit multiple directories from executing php

location ~* ^/(download|down)/.*\.(php|php5)$
{
deny all;
}
Copy after login

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;
}
Copy after login

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!

Related labels:
php
source:whsir.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template