0

I've written a web application which has an assets folder. This folder containts a bunch of images, JavaScript and CSS files. If a user writes in sub.domain.com/assets then a default listing appears, which displays the various folders, files and images. Should I hide the content of this folder? They cannot find anything that can't be found on the website anyway. If I should hide this, how should I do it? I tried to use Option -Indexes and the like, but after saving it like that not even my php scripts could access my JS and CSS files, images. I am using the Apache webserver btw.

Thanks in advance!

masm64
  • 1,222
  • 3
  • 14
  • 31
  • 2
    You're fishing for opinions. it's entirely up to you to decide what should be visible and what should be hidden. – Marc B Jul 07 '15 at 21:23
  • but if you hid it, how would you do it? – masm64 Jul 07 '15 at 21:25
  • A really simple way is to create an index.html file in each folder, otherwise, you h – Sacreyoule Jul 07 '15 at 21:28
  • If you don't want people to see the files without a direct link, use use `Options -Indexes`. If you want them to be secure, use PHP to directly download them, or use an Apache module (forgot the same) which allows them to be controlled by PHP – user1032531 Jul 07 '15 at 21:28

1 Answers1

1

You've got two options really. The easiest one to do would be create a blank index.html file and place it in the folder(s) that you do not want the directory listing to appear for.

The second being through the use of .htaccess, where all you need to do is create or edit an .htaccess file in the root of the folder and add Options -Indexes as a line. Save it ensuring that it is not saved with an extension (like .txt) or anything and that should prevent the contents being listed.

If you want to recursively do this for a whole directory and its subdirectories I recommend the method outlined in this post.

Community
  • 1
  • 1
Daniel Waghorn
  • 2,997
  • 2
  • 20
  • 33