K
K
Konstantin Khairov2019-01-02 21:55:03
Apache HTTP Server
Konstantin Khairov, 2019-01-02 21:55:03

How to deny access by IP to a folder with pictures on apache?

Hello . There is a folder in public_html . It's called /uploads/
This folder has a folder where pictures are stored. It is called posts
In the /uploads/ folder, I uploaded the .htaccess file in which I wrote

<Directory /posts/>
Order deny, allow
deny from all
Allow from 217.30.160.0/20 217.29.112.0/20 217.12.80.0/21 213.230.64.0/18 213.206.32.0/19 212.115.112.0/22 и там еще около 90 IP сетей 
</Directory>

I go to the site whose IP is by no means included in any of these ranges. There is a link to download the image. I insert. And it is downloaded, that is, this rule does not work. I try to open a picture through a WEB proxy and get the same thing. What is the problem? Why doesn't it work? Thank you all in advance for help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-01-02
@dodo512

httpd.apache.org/docs/2.4/mod/core.html#directory
<Directory> can only be used in the context of server config, virtual host.
If you push it into .htaccess, there will be an error 500
. there is no error and the pictures are downloaded, then either it is specified in the settings AllowOverride Noneand Apache does not read .htaccess, or the pictures are distributed without its participation at all, for example, Nginx.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question