Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache2.4 Internal Server Error DirectoryMatch

I'm trying to secure the .git and svn directories from anyone being able to access them because they contain sensitive meta information.

I've tried using the following rule but I'm receiving an internal server error and I'm not sure why:

<Directorymatch "^/(.*/)*\.(git|svn)/">
    Require all denied
</Directorymatch>

Any ideas?

like image 279
Karl Avatar asked Nov 23 '16 16:11

Karl


1 Answers

As per Apache 2.4 documentation, DirectoryMatch directive is not allowed in .htaccess

You can use mod_rewrite directives to do the same in your site root .htaccess:

RewriteEngine On

RewriteRule \.(git|svn)(/.*)?$ - [F,NC]
like image 115
anubhava Avatar answered Nov 12 '22 20:11

anubhava