Home  >  Article  >  Backend Development  >  How does htaccess prevent a directory from executing php methods?

How does htaccess prevent a directory from executing php methods?

藏色散人
藏色散人Original
2020-08-18 09:03:184241browse

htaccess method to prohibit directory execution of php: First create a new htaccess file in the directory to be prohibited; then enter the content as "php_flag engine off" and save it.

How does htaccess prevent a directory from executing php methods?

Recommended: "PHP Video Tutorial"

.htaccess prohibits directory execution php method

System: centos 5.9

Environment: lamp

How to disable suffixes in apache:

Here we only demonstrate how to disable php execution, and the rest are a little bit Just change it simply. Create a new .htaccess in the directory you want to ban. The content is:

The code is as follows

<FilesMatch ".(php.|php3.)">
Order Allow,Deny
Deny from all
</FilesMatch>

or

Create one in the required directory .htaccess file and write a line in it

The code is as follows

php_flag engine off

Of course you can also write it into httpd.conf, but in that case you have to restart apache, which is not very good.

Attached nginx prohibits directory execution php

The code is as follows

location ~ /(attachments|upload)/.*.(php|php5)?$ {
deny all;
}

The above is the detailed content of How does htaccess prevent a directory from executing php methods?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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