Prevent File Browsing with .htaccess
Need to block access to a directory on your site?
If your hosting environment runs the Apache web server, you can simply create an .htaccess file in the directory you’d like to protect and insert the following code:
Options -Indexes
For example, say you’ve created a sub-folder on your site to hold images. Without protection, a user could visit http://yoursite.com/images/ and see a directory listing of the files and folders in the images directory.
By simply creating a file with the above line and saving it as .htaccess in the images directory, users will get an error rather than a directory listing when they visit the URL.
For more info on .htaccess, visit the Apache website.
March 12th, 2008 at 08:19
Thanks, just what I needed
March 12th, 2008 at 08:21
No problem – glad it helped. 🙂
December 28th, 2008 at 10:41
This works great thanks! great use when you haven’t got access to the server’s config file.