The pertinent part of my .htaccess looks like this:
Options -Indexes
Order allow,deny
Deny from all
Re
With rewrite mod:
RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*/\.
RewriteRule ^(.*)$ - [R=404]
Every file or dir who begin with a dot will be redirected to 404.
/myDir/.svn => 404
/.gitignore => 404
/dir1/dir2_dir3/
Or to change all 403,400 errors into 404 errors, put this at the end of /etc/apache2/conf.d/localized-error-pages OR into a .htaccess
# Will raise a 404 error, because the file doesn't exist.
# We change 403 or 400 to 404 !
ErrorDocument 400 /fake_file_for_apache_404.php
ErrorDocument 403 /fake_file_for_apache_404.php
# We need to rewrite 404 error, else we will have "fake_file_for_apache_404.php not found"
ErrorDocument 404 "404 Not Found Not Found
The requested URL was not found on this server.
"
ErrorDocument 500 "Server in update. Please comme back later."