Home > Article > Backend Development > How to set nginx to prohibit parsing php files
nginx sets the method to prohibit parsing PHP files: PHP parsing can be restricted based on the directory. Specific method: First open the configuration file; then find the configuration [location ~ .php$] and set it to [deny all].
Specific method:
(Recommended tutorial: nginx tutorial)
Restrict php parsing
Restrict php parsing based on directory:
location ~ .*(diy|template|attachments|forumdata|attachment|image)/.*\.php$ { deny all; }
Restrict browser access
Use user_agent to control client browser access
location / { if ($http_user_agent ~ 'bingbot/2.0|MJ12bot/v1.4.2|Spider/3.0|YoudaoBot|Tomato|Gecko/20100315'){ return 403; } }
Related recommendations: php training
The above is the detailed content of How to set nginx to prohibit parsing php files. For more information, please follow other related articles on the PHP Chinese website!