PHP script file is forbidden by Apache Nginx Directory execution method

Source: Internet
Author: User
This article mainly introduces the Apache Nginx ban Directory execution php script file method, the content is very good, and now share to everyone, but also for everyone to make a reference.

When we build our website, we may need to set permissions on some directories individually to achieve the security we need. Below is an example of how to disable a directory execution PHP file under Apache or Nginx.

1.Apache Configuration

<Directory/apps/web/renwole/wp-content/uploads> Php_flag engine off</directory><directory ~ "^/apps/ Web/renwole/wp-content/uploads "> <files ~". php "> Order allow,deny deny from all </files></directory >

2.Nginx Configuration

location/wp-content/uploads {location  ~. *\. ( PHP)? $ {  deny all;  }}

Nginx prohibits multiple directories from executing PHP:

Location ~* ^/(css|uploads)/.*\. (PHP) ${  deny all;}

After the configuration is complete, reload the configuration file or restart the Apache or Nginx service, and all access to the PHP file via uploads will return 403, greatly increasing the security of the Web directory.

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.