block access to a given directory via htacess

1

Well I have a folder in the root of my site called logs . Inside it I will save the logs which custom errors I mount.

Well, I need to block this folder so that it can not be accessed by anyone, just by me via ftp.

But php can create files with error logs inside.

I found several form to put password in it with htacess, however do not want by password, I want to block it definitely not to be accessed via browser.

Is there any way to do this with htacess?

I'm using Apache.

I tried to do this:

<Directory "Logs">
   Order allow,deny
   Deny from all
</Directory>

But it gave the server an internal error.

    
asked by anonymous 19.07.2017 / 18:16

2 answers

1

Block access completely

Create the .htaccess file inside the folder you want to protect

Deny from all

NOTE: In addition, no script has access to this folder

Partially block access

Create the .htaccess file inside the folder you want to protect

<IfModule mod_rewrite.c>
    Options -Indexes
</IfModule>

NOTE: When accessing the folder through the browser gives access denied (error 403), however, PHP can access.

    
20.07.2017 / 22:46
0

enter in your apache2.conf or httpd.conf use the Define directive to point where your package is installed.

 Define INSTALL_DIR [diretorio a ser instalado]

Ex: Windows

Define INSTALL_DIR c:\wamp64

Then use the following setting.

<Directory "${INSTALL_DIR}/www/Logs/">
   Deny from all
</Directory>
  

Remembering that Define [nome] [conteudo]
   When you are going to maintain or configure Directorys, always try to go through the configuration path

If it is not for Windows speak, but I think it works for Linux as well.

    
20.07.2017 / 23:30