Block direct file access

Asked

Viewed 323 times

0

I need to block direct access to files in a directory, for example public_html/repositorio.
In this folder (repository) contains images (jpg), pdfs etc.
I don’t want anyone to directly access this folder (listing its content) or directly access one of the files via www.meusite.com.br/repositorio/abc.jpg
I used in the . htaccess file the following command: Options -Indexes. It blocked the file listing when I input www.meusite.com.br/repositorio/, but allows me to access the file directly.

IMPORTANT: I already used the command Deny from all on htaccess and it blocked access to the file. But when I access my site, the image also does not open...

Thanks for the help.

  • 1

    What you need to do is block only hotlink to the image, ie taking your site any other would be blocked. and for that there is this solution: How to Block Image Hotlinks with Warning?

  • Thanks for the help, but it didn’t work out. My . htacess is like this, what could be wrong? Options -Indexes Rewriteengine On Rewritecond %{HTTP_REFERER} ! http://(.+.)? peticoes.tecologia.Ws/ [NC] Rewritecond %{HTTP_REFERER} ! $ Rewriterule . *.(jpe?g|gif|bmp|png) $ [L] Please note that http://peticoes.tecnologia.ws/repositorio/imagem_principal/ is blocking the listing, but http://peticoes.tecnologia.ws/repositorio/imagem_principal/140800001.jpg presents the image...

  • puts your code in the question, gets better to see

No answers

Browser other questions tagged

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