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

How does htaccess prevent a directory from executing php methods?

藏色散人
Release: 2023-03-04 16:42:01
Original
4321 people have browsed it

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

or

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

The code is as follows

php_flag engine off
Copy after login

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

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!

Related labels:
source:php.cn
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
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template