diff --git a/.htaccess b/.htaccess
index 230f6ae330f3281ee6195cc6993ab0541281abac..05d142348b539e2972757df2dc1e4bcb5d58f5c6 100644
--- a/.htaccess
+++ b/.htaccess
@@ -50,9 +50,6 @@
 
   # Rewrite rules for `front_controller_active`
   Options -MultiViews
-  <IfModule mod_dir.c>
-    DirectorySlash off
-  </IfModule>
   RewriteRule ^core/js/oc.js$ index.php/core/js/oc.js [PT,E=PATH_INFO:$1]
   RewriteRule ^core/preview.png$ index.php/core/preview.png [PT,E=PATH_INFO:$1]
   RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff)$
diff --git a/lib/private/setup.php b/lib/private/setup.php
index 814d78679e276b2a50cd3638961e7bcc31306ac4..869a87fbf13e8c40bd0db50aa4f771a8a59afddf 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -439,6 +439,9 @@ class Setup {
 		$content.="\n  RewriteBase ".$webRoot;
 		$content .= "\n  <IfModule mod_env.c>";
 		$content .= "\n    SetEnv front_controller_active true";
+		$content .= "\n    <IfModule mod_dir.c>";
+		$content .= "\n      DirectorySlash off";
+		$content .= "\n    </IfModule>";
 		$content.="\n  </IfModule>";
 		$content.="\n</IfModule>";