P
P
Pavel Novikov2019-02-25 13:08:12
htaccess
Pavel Novikov, 2019-02-25 13:08:12

How to hide the folder with files in the public directory of the site?

Hello, I have a Symfony4 project whose public directory is /public.
In this directory, I have a couple of folders that contain files. Can I somehow prevent access to these files through direct links? For example, if a user enters the address mysite.com/uploads/img/file.jpg in a browser, then he would not be able to see this file.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2019-02-25
@paulfcdd

<Files uploads/img/*>
    deny from all
</Files>

But you need to understand that these files will no longer be accessible from the browser at all - they cannot be inserted into the page in , it will not be possible to connect them via CSS, etc. If you want them to be available as resources, but they cannot be seen by typing the full path in the browser, then, of course, this cannot be done. <img/>

W
wisgest, 2019-02-26
@wisgest

Maybe. It's called "hotlink protection". But if the user in the browser settings prohibits the transfer of Referer, then he will not see the pictures in any case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question