Home >Backend Development >PHP Problem >How does htaccess prevent a directory from executing php methods?
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.
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!