Prevent access to files in a certain folder

前端 未结 4 1181
有刺的猬
有刺的猬 2021-01-03 23:05

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

4条回答
  •  梦毁少年i
    2021-01-03 23:30

    1. Create .htaccess file inside the desired folder with the following contents:

      Deny from all

    2. 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 tag)

      AccessFileName .htaccess

    3. Edit your site's configuration file only in case you have a tag specified inside it and add the following line:

      AllowOverride ALL

    4. 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/

提交回复
热议问题