From 4c2f51256f2c914a10c0c7aa59311c5862d2a480 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 20 Jan 2018 16:20:53 +0100 Subject: [PATCH] htaccess: prevent accessing resources not managed by SCM See: - https://en.internetwache.org/dont-publicly-expose-git-or-how-we-downloaded-your-websites-sourcecode-an-analysis-of-alexas-1m-28-07-2015/ - https://stackoverflow.com/questions/2530372/how-do-i-disable-directory-browsing - https://httpd.apache.org/docs/current/mod/mod_rewrite.html Signed-off-by: VirtualTam --- .htaccess | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.htaccess b/.htaccess index 66ef8f69..19dd72a8 100644 --- a/.htaccess +++ b/.htaccess @@ -1,4 +1,12 @@ +# Disable directory listing +Options -Indexes + RewriteEngine On + +# Prevent accessing subdirectories not managed by SCM +RewriteRule ^(.git|doxygen|vendor) - [F] + +# REST API RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [QSA,L]