Prohibit PHP execution permission for a directory under Apache

  
                  

In the IIS environment, the script execution permission of the directory can be set in the Internet Information Services (IIS) Manager.

How to set up in Apache environment?

I found two options:

Scenario 1) Restricting requests for .php files via .htaccess.

Create a .htaccess file in the directory where you want to cancel the PHP execution permissions, enter the following content and save it.

<Files ~ ".php">

order allow,deny

deny from all

</Files>

The premise is that your Apache has URL rewriting enabled.

Scenario 2) Set in the Apache configuration file.

Find the corresponding virtual host section, add the following content, and then restart httpd.

<Directory "Directory path to remove PHP execute permissions">

<Files ~ ".php">

Order allow,deny

Deny from all

</Files>

</Directory>

Currently I am using option 1, I feel so flexible . And for virtual hosts that don't generally have Apache permissions,

Copyright © Windows knowledge All Rights Reserved