diff --git a/apps/user_ldap/tests/.htaccess b/apps/user_ldap/tests/.htaccess
index 5e068d28661f9395b476a41b3d026733464007fa..6fde30e763a604f48fdb949d3090a455dc6fa68b 100755
--- a/apps/user_ldap/tests/.htaccess
+++ b/apps/user_ldap/tests/.htaccess
@@ -11,4 +11,6 @@ Satisfy All
 </ifModule>
 
 # section for Apache 2.2 and 2.4
+<ifModule mod_autoindex.c>
 IndexIgnore *
+</ifModule>
diff --git a/build/.htaccess b/build/.htaccess
index c7a7b79feac0a42617fa026290f1047cfcf44943..853aed187d3e72639fbec68fba143c65c9697bb3 100644
--- a/build/.htaccess
+++ b/build/.htaccess
@@ -9,4 +9,6 @@ deny from all
 </ifModule>
 
 # section for Apache 2.2 and 2.4
+<ifModule mod_autoindex.c>
 IndexIgnore *
+</ifModule>
diff --git a/config/.htaccess b/config/.htaccess
index c7a7b79feac0a42617fa026290f1047cfcf44943..853aed187d3e72639fbec68fba143c65c9697bb3 100644
--- a/config/.htaccess
+++ b/config/.htaccess
@@ -9,4 +9,6 @@ deny from all
 </ifModule>
 
 # section for Apache 2.2 and 2.4
+<ifModule mod_autoindex.c>
 IndexIgnore *
+</ifModule>
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index 321e8ea4c6606b2fa33e3953432c84b4408091c9..b20614f897195ff6f27f0fc251e3f63fbc627897 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -492,7 +492,9 @@ class Setup {
 		$content.= "Satisfy All\n";
 		$content.= "</ifModule>\n\n";
 		$content.= "# section for Apache 2.2 and 2.4\n";
+		$content.= "<ifModule mod_autoindex.c>\n";
 		$content.= "IndexIgnore *\n";
+		$content.= "</ifModule>\n";
 
 		$baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
 		file_put_contents($baseDir . '/.htaccess', $content);