Home > Backend Development > PHP Problem > How to set apache to disable php

How to set apache to disable php

藏色散人
Release: 2023-03-01 22:46:02
Original
2700 people have browsed it

How to ban php in apache: first create a new ".htaccess" file; then copy the code content "Order allow,deny" to the ".htaccess" file; finally, copy the file directly Just put it in the root directory of the website.

How to set apache to disable php

How to configure apache to configure the upload directory to prohibit running php

Security protection There are many security issues caused by the website upload function , have you taken safety precautions?

Introduction: Prohibiting the uploading directory from running executable files such as php can increase the security of the website to a certain extent. The method of prohibiting the uploading directory from running php can use the .htaccess file, or you can modify the configuration directly on the apache server. File.

The first method to prohibit the upload directory from running php

If you use a virtual space, you can use the .htaccess file to restrict the upload directory from running 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>
Copy after login

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

Second method: Modify the Apache configuration file

Add the following content to the configuration:

">
<Files ~ ".php">
Order allow,deny
Deny from all
</Files>
Copy after login

Many For relevant knowledge, please visit PHP中文网!

The above is the detailed content of How to set apache to disable php. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template