Reputation: 9880
I am currently on a shared host and my files and folders are placed inside "public_html". In this, I have a folder that consists more folders inside it along with many pdf files. So the folder looks like this:
FOLDER/folder1/xyz.pdf
FOLDER/folder2/abc.pdf
etc..etc..
I am trying to figure out a way to deny access to the folder directly through a browser but not deny access to the files in it. At the moment, when someone goes to my site as www.mysite.com/FOLDER, you can access the folder and see its contents through a browser itself. But I dont want to deny complete access to the folder since I have links to its pdf files in some of other pages on my site like: Click here
Can someone guide me on I can restrict the direct access to the folder but not deny access to its files plz?
EDIT: I am thinking, do I just create an index.html file in every folder?
Upvotes: 4
Views: 2594
Reputation: 2541
Better solution will be to use
Options -Indexes
It will forbid the contents of a directory to be displayed if it has no index file. The best thing is that it will not display the header of the directory like
IndexIgnore *
Cheers, Chris
Upvotes: 3
Reputation: 4161
I would suggest using htaccess and adding the IndexIgnore command:
IndexIgnore *
Put it in a file and call it .htaccess (Not .htacces.txt, only .htaccess)
Another option is to prevent only one kind of file from being indexed:
IndexIgnore *.pdf
You can ignore any file type: " *.pdf *.zip *.jpg *.png *.html(bad idea! :P )"
I hope this helps :)
Upvotes: 4