Blog by Andreas Glaser

.htaccess - How to restrict browsing through directories

by Andreas Glaser on Oct.28, 2008, under Computer, Development

If you want to prevent users from browsing certain directories on your website you can use the powerful .htaccess  file (Apache only). With the .htaccess file you are able to override some default settings like allowing / denying users to browse through directories. This is very useful when you use a certain directory to save for instance: templates, pictures, files or similar things (e.g. http://www.yourdomain.com/files).

How to prevent users from browsing through directories…

  1. Create a new file (txt) and rename it to .htaccess
  2. Insert the following string into your new .htaccess file:
    1
    2
    3
    
    # DENY CLIENTS TO BROWSE THE CURRENT AND ALL SUB DIRECTORIES
     
    Options All -Indexes
  3. Upload this file into the directory which shall be not allowed to browse.

Thats it!

So long,
Andreas Glaser (aka JaZz)

:, , ,
1 comment for this entry:
  1. Stelian

    This will affect robots from browsing directories with forbiten acces if i don`t have any index ?

    Thanks

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...