. htacess Restricted Directory Upload asp,php,jsp,asp.net file method

Source: Internet
Author: User

The Apache environment rules are as follows: Apache executes PHP script restrictions to add these rules to the. htaccess file

The code is as follows Copy Code
Rewriteengine on Rewritecond%!^$
Rewriterule uploads/(. *). (PHP) $–[f]
Rewriterule data/(. *). (PHP) $–[f]
Rewriterule templets/(. *). (PHP) $–[f]

The NGINX environment rules are as follows: Nginx Execute PHP script restrictions

LNMP has a disadvantage is that directory permissions are not as good as Apache, and sometimes the Web site program has uploaded vulnerabilities or similar pathinfo vulnerabilities, which led to the upload of the PHP trojan, and to the Web site and the server to bring greater danger. It is recommended to remove the PHP permissions from the Site directory and return 403 errors when accessing the PHP file under the upload directory.

To edit the Nginx virtual host configuration First, add the following in front of the fastcgi location statement:

The code is as follows Copy Code
Location ~/(data|uploads|templets)/.*. (PHP|PHP5)? $ {
Deny all;
}

Okay, Nginx's Apache rules are a little different, but not very different.

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.