I have a folder with a lot of .php
files. I would like to deny access to them (using .htaccess
). I know an option is to move this folder outside
Create .htaccess file inside the desired folder with the following contents:
Deny from all
Edit apache2.conf
or httpd.conf
, whatever you find in Apache2 directory (probably located in /etc/apache2
). You'll need to edit/check the following:
AllowOverride ALL
(in the related
AccessFileName .htaccess
Edit your site's configuration file only in case you have a
AllowOverride ALL
Restart your Apache2 server
service apache2 restart
The above steps are all meant for Linux environments. The same instructions would work well for Windows environments except for the paths and the server restart command.
Reference: http://www.cyberciti.biz/faq/apache-htaccess/