Disabling the Directory browsing of apache2, you can use one of the options below.
Option 1: Via command:
a2dismod autoindex
After that the apache2
/etc/init.d/apache restart
Option 2: Editing apache configuration file
Old location: Find your file httpd.conf usually in the path /etc/apache/httpd.conf (source of that information seems this outdated)
Most recent location: Search the site configuration file by default is 000-default.conf
and is in the path /etc/apache2/sites-enabled/
Look for a line similar to the one shown below
Options Includes Indexes FollowSymLinks MultiViews
Remove the text Indexes
as shown below
(if you do not have one of the items shown is not necessary to add, the important here and you take the Indexes)
Options Includes FollowSymLinks MultiViews
After that the apache2
/etc/init.d/apache restart
Option 3: only in a specific directory
Another method is to create a file .htaccess
inside the folder you want to disable this Feature and put as content
Options -Indexes
Option 4: Create a file index.php
or index.html
Placing an index.php or index.html file in the folder when the user tries to access the folder will fall within the index you created and not the apache automatic index.
[NOTE]: In case you want to hide the image path you can create a file php to act as an image, simply upload the image data to a variable (such as using the function file_get_contents('imagem.png')
) and use one of the examples in this reply
Sources: stackoverflow - EN
If the browser can open the signficia image that the user can also, even if you code the user can also take the coded code and decoficarlo, if you want to hide the original address of the image, could try htaccess;
– Leo Letto
you can open the file and present the Base64 as
data:url
this will not prevent the user from copying the image... but will not expose its address on the server that in case does not need to be in the structure accessible to the client.– Leandro Angelo
Why do you want to hide the url of
src
for the user?– RXSD
You are wanting the user not to be able to access the folder and see all the files in it ? (browsing directory)
– Icaro Martins
@Icaromartins like that
– Isaque
You’re wearing
apache2
?– Icaro Martins
@Icaromartins yes I am using apache.
– Isaque