What is the best way to hide a websites folder/ directory files

kevin ols picture kevin ols · Oct 18, 2013 · Viewed 40.5k times · Source

If I would visit my website by "www.mysite.com/img/"

I would see the following:

Parent directory...

folder1

folder2

file1

file2

etc etc..

But what is the best way to prevent people from visit my websites folders and file structure?

While still letting pople view eg the images on the actual website

I also want to hide eg www.mysite.com/functions/ where I have my php function-files.

Checking on google shows me alot of ways to do this,

but what is the best and safest way?

Thanks in advance!

Answer

cdonts picture cdonts · Oct 18, 2013

Create an index.html or index.php file inside, for example, the img folder; so when a visitor attempts to visit yourwebsite.com/img/ and see the content, index.html will be showed instead.