-1

is there a way to avoid a user from viewing the content of my website img folder ? For example if a visitor inspect the site with google chrome devtools, I don't want to show the content of the website img folder

NOTE: with directory listing I am able to hide the content of my img folder by visiting the url: wwwmysite.com/img --> FORBIDDEN but inspecting the site with the devtools the content of the img folder is still visible

Mamulasa
  • 543
  • 4
  • 14
  • 24
  • http://stackoverflow.com/q/5932641/80836 - deny directory listing with htaccess – Andreas May 14 '17 at 19:07
  • Possible duplicate of [deny directory listing with htaccess](http://stackoverflow.com/questions/5932641/deny-directory-listing-with-htaccess) – gp_sflover May 14 '17 at 19:10
  • with directory listing I am able to hide the content of my img folder by visiting the url: wwwmysite.com/img --> FORBIDDEN but inspecting the site with the devtools the content of the img folder is still visible – Mamulasa May 14 '17 at 19:19

3 Answers3

1

Add a index.html in image folder, like this people won't be able to see all the content of the folder.

Pol
  • 1,132
  • 1
  • 11
  • 35
0

If you are talking about uploads, then the solution is quite simple: you put the upload folder outside DOMCUMENT_ROOT. Kinda like what are (or should be) doing from your PHP code.

Then you set up .htaccess to load all uploaded images though a PHP file.

And when you have such a setup, you can also start adding additional security features, like checking a cookies, before loading an image, if the user accessed the "parent html page", before loading the image and other solutions.


Alternatively, if all you want to stop is directory listing, you just use Options -Indexes in your webserver's config.

tereško
  • 58,060
  • 25
  • 98
  • 150
0

If index.html won't work try rename it to default.html or maybe to main.html. Actually you can look at the server configuration.

Maybe this will assist you: Why does index.html have priority over index.php?

Community
  • 1
  • 1
A. Meshu
  • 4,053
  • 2
  • 20
  • 34