block access to a particular directory via htacess

Asked

Viewed 1,900 times

1

Well I have a folder at the root of my site called logs. Inside it I will save the logs that custom bugs that mount.

Good need to lock this folder not to be accessed by anyone, just by me via ftp.

But php can create error log files inside.

I found several form to put password in it with htacess, but I 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 the apache.

I tried to do so:

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

However there was internal error in the server.

2 answers

1


Block the access completely

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

Deny from all

NOTE: inclusive, no script has access to this folder

Block access in part

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 have access.

  • inside that folder will get some logs, I need php to have permission to create the files. if I use the Deny from all php will get that permission?

  • @Hugoborges the answer is in accordance with the original question where you say "...not to be accessed by anyone, only by me via ftp". Rephrase p.f. your question.

  • I’m sorry, I forgot to inform you of this situation. I’ve changed my question.

  • @Hugoborges updated my answer. Check p.f. if it works.

0

enter your apache2.conf or httpd.conf use the directive Define to point out 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]
so if you want you can give another name, or look for an already configured directive.
When maintaining or configuring Directorys always try to give every configuration path

If it’s not Windows talk, but I think it’s good for Linux too.

  • inside that folder will get some logs, I need php to be allowed to create the files. that way php will get this permission?

  • Yes php has access to creating folders inside with this configuration.

  • Well this way gave error 500, I’m using linux, I’ll see what may be happening. But vlw by help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.