Apache: disable php in directory

I want to disable php in a directory on my server. I thought setting the -ExecCGI options to httpd.conf would prevent php scripts from executing, but obviously I'm wrong.

So this is what I have in my httpd.conf, which obviously does not work:

<Directory "C:/xampp/htdocs/(path_to_directory)/dirname">
    Options -ExecCGI
    AllowOverride None
</Directory>

The question is, how can I prevent php scripts from executing in a specific folder? Could it be done in httpd.conf or do I need to use a .htaccess file?

+1
source share
2 answers

you can do this with a .htaccess file. you need to put the .htaccess file in a folder in which you don't want to execute php with the following htaccess code.

<Files *.php>
deny from all
</Files>

. http://www.wpbeginner.com/wp-tutorials/how-to-disable-php-execution-in-certain-wordpress-directories/

.htaccess:

php_flag engine off
+5

php_flag engine off , mod_php ( mod_php7.x), php-fpm

, php-fpm, httpd.conf:

<Directory "C:/xampp/htdocs/(path_to_directory)/dirname">
<FilesMatch ".+\.*$">
SetHandler !
</FilesMatch>
</Directory>

.htaccess PHP:

<FilesMatch ".+\.*$">
SetHandler !
</FilesMatch>

Unix, Windows, , U.

+3

Source: https://habr.com/ru/post/1599568/


All Articles