Home >Backend Development >PHP Problem >How to prevent apache from executing php
How to prohibit the execution of php in Apache: first create a new ".htaccess" file; then copy the code content "Order allow, deny" to the ".htaccess" file; finally put the file directly into the root directory of the website Just inside.
How to prohibit apache from executing php:
The first method to prohibit uploading directories from running php
If you use a virtual space, you can use the .htaccess file to limit the upload directory to run php.
.htaccess method A
Create a new .htaccess file, copy the following content, and upload it to the folder where you want to prohibit running php
<Files ~ ".php"> Order allow,deny Deny from all </Files>
.htaccess method B
Put it directly into the root directory of the website to limit multiple directories:
RewriteEngine on RewriteCond % !^$ RewriteRule uploads/(.*).(php)$ – [F] RewriteRule data/(.*).(php)$ – [F] RewriteRule templets/(.*).(php)$ –[F]
Second method: Modify the Apache configuration file
Add the following content to the configuration:
<Directory /www/www./upload> php_flag engine off </Directory> <Directory ~ "^/www/.*/upload"> <Files ~ ".php"> Order allow,deny Deny from all </Files> </Directory>
If you want to know more about programming learning, please pay attention to the php training column!
The above is the detailed content of How to prevent apache from executing php. For more information, please follow other related articles on the PHP Chinese website!