Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 701
kevin ols Avatar asked Oct 18 '13 00:10

kevin ols


People also ask

How do I hide files from a website?

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.

How do I hide files and folders?

To hide one or more files or folders, select the files or folders, right-click on them, and select Properties. On the General tab on the Properties dialog box, check the Hidden box in the Attributes section. To prevent the files or folders from appearing in Windows search results, click Advanced.


2 Answers

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.

like image 83
cdonts Avatar answered Oct 25 '22 11:10

cdonts


If your server is Apache you can setup an .htaccess file and build rules to hide/redirect and return a 404 Error page.

If your server is IIS then you can modify the "URL Rewrite" rules in your IIS Manager to return a 404 Error/Forbidden page.

See: .htaccess tips & tricks

like image 38
Mauro H. Leggieri Avatar answered Oct 25 '22 12:10

Mauro H. Leggieri