views:

308

answers:

3

I have a (Wordpress powered) website, and Google is indexing some of the sub-directories. How can I stop Apache from showing users the directory listing? I know I can edit .htaccess to password-protect a directory, but I would prefer a 403 / custom redirect if possible.

+3  A: 

Look at your robots.txt rules, and make sure apache is not serving-up directory listings.

see http://httpd.apache.org/docs/2.0/howto/htaccess.html && http://www.webmasterworld.com/forum92/5272.htm

warren
+12  A: 

You need this entry in your .htaccess file:

Options -Indexes
Ates Goral
A: 

Don't know much about Apache but you should do a 404 instead of a 403 if you can because a 403 tells someone that they may have found something interesting.

Flory
You're suggesting that people use an incorrect error code to avoid people thinking they're not allowed to access something that they can't access? What? Moreover, the mediocre security-by-obscurity you're suggesting could also be achieved by correctly returning a 403 where disallowed and not found.
eyelidlessness