Forum Moderators: phranque
I am the webmaster for a scouting website and i have many directories for which people may browse and access content which should really only be displayed on pages (if you know what i mean). I am pretty sure you can use .htaccess to block directory browsing however i do not have the knowhow,
Please help
James
You can simple drop an .htaccess file in that directory with a directive setting of
Options -IndexesHave a look at the following Apache documentation for more infommation:
mod_autoindex [httpd.apache.org]
DirectoryIndex [httpd.apache.org]
Many Thanks
[edited by: rogerd at 2:50 pm (utc) on Jan. 3, 2005]
[edit reason] examplified [/edit]
This tutorial should help:
Apache Tutorial: .htaccess files [httpd.apache.org]
If the .htaccess file already exists, see if it contains lines like these up at the top of the file:
Options -Indexes
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
If it doesn't, you'll want to add those lines, or at least the first of the two lines.
If you don't have an .htaccess file yet, make one.
Open Notepad or some other text editor you have.
You can even start with just those two lines above.
Save the file to your harddrive, calling it
".htaccess" (use the quotes)
Then just transfer the saved file to the root directory of your website.
Kick me a stickymail and we'll swap url's if you want, because under our TOS here we don't self-promote sites here. may be aspell before I see it as I'm close to being out the door.
Options -Indexes
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
onto a word file, saved it as a text file then once loaded onto the root directory i renamed it .htaccess instead of .htaccess.txt. This made the homepage show a page called internal server error what to do?
The only line you should need is the
Options -IndexesAlso, why are you dropping the .htaccess file in your root directory? You said the images were in a subdirectory, right? Make sure you place the .htaccess file in the directory in which you do not want the file listings.
Welcome to WebmasterWorld!
If you're getting a 500-Server Error on Options, you'll need to contact your host and ask them to configure your account with
AllowOverride Options AllowOverride All Otherwise, you have two choices: You can create a page called "index.html" in that directory, presenting a "directory listing not allowed" message, or use a meta-refresh on that page to redirect the browser to some other page. Or, you can change hosting providers, looking for one that will allow you to properly control access to your site.
Jim