Apache:在目录中禁用php [英] Apache: Disable php in a directory
问题描述
我想在服务器上的目录中禁用php. 我以为在httpd.conf中设置Options -ExecCGI可以防止执行php脚本,但是显然我错了.
I want to disable php in a directory on my server. I thought that setting Options -ExecCGI in httpd.conf would prevent php scripts from being executed, but obviously I am wrong.
所以,这就是我的httpd.conf中的内容,它显然不起作用:
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>
问题是,如何防止php脚本在特定文件夹中执行? 可以在httpd.conf中完成,还是必须使用.htaccess文件?
The question is, how can I prevent php scripts from being executed in a specific folder? Can in be done in httpd.conf or do I have to use a .htaccess file?
推荐答案
您可以使用.htaccess文件执行此操作.您需要将.htaccess文件放在您不想使用以下htaccess代码执行php的文件夹中.
you can do this with .htaccess file. you need to place a .htaccess file in the folder you don't want to execute the php with following htaccess code.
<Files *.php>
deny from all
</Files>
更多详情请参见此处您还可以尝试禁用引擎选项在您的.htaccess文件中:
Also you can Try to disable the engine option in your .htaccess file:
php_flag engine off
这篇关于Apache:在目录中禁用php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!