Is it possible to force a 404 error if someone tries to access any directory in my root directory (/var/www) provided the directory name contains .git?
I.e if someone tried to access http://mysite.com/site.git, it would show a 404 page?
Furthermore, how could I prevent directory listing in the same file?
I am using Apache/2.2.22 (Ubuntu).
Thanks,
Max.
Using mod_rewrite, you can put these rules in the htaccess file in your document root:
Or, you can replace the brackets with a
[F,L]to return a 403 Forbidden instead.