fix apache rewrite generation
authormutec <mysterycode@mysterycode.de>
Mon, 7 Oct 2019 10:16:03 +0000 (12:16 +0200)
committermutec <mysterycode@mysterycode.de>
Mon, 14 Oct 2019 14:39:41 +0000 (16:39 +0200)
Before this change the system wasn't able to handle nested directories properly.
A multidomain-setup using a different domain for every app and having them on the same file tree level was required for a valid output.
Now it's handling the "default"-case properly which might be one app at `/` and others in sub-directories.

Technical:
The algorithm didn't decide correctly if an app is placed in a sub-directory of another app. Now it's removing extra htaccess-files for those sub-directories and places everything correctly in the highest folder handling every app and the root-app at last.

wcfsetup/install/files/lib/data/option/OptionAction.class.php

index 6a35e274dcb40af73c08f0ded7ed4194fa390898..8dcfee9ac1974e54ce038f1e772392c40ab91243 100644 (file)
@@ -148,8 +148,6 @@ class OptionAction extends AbstractDatabaseObjectAction {
                        foreach ($dirs as $dir => $apps) {
                                if (strpos($dir, $test) !== false) {
                                        unset($dirs[$dir]);
-                                       $insert = false;
-                                       break;
                                }
                                else if (strpos($test, $dir) !== false) {
                                        $insert = false;
@@ -173,14 +171,16 @@ class OptionAction extends AbstractDatabaseObjectAction {
                        
                        foreach ($domainPaths as $domainPath => $value) {
                                $htaccess = "{$dir}.htaccess";
-                               if (empty($rules['apache'][$htaccess])) {
-                                       $path = FileUtil::removeTrailingSlash(substr($value, strlen($dir)));
-                                       $rules['apache'][$htaccess] = <<<SNIPPET
+                               $path = FileUtil::removeTrailingSlash(substr($value, strlen($dir)));
+                               $content = <<<SNIPPET
 RewriteCond %{SCRIPT_FILENAME} !-d
 RewriteCond %{SCRIPT_FILENAME} !-f
 RewriteRule ^/{$path}(.*)$ {$path}/index.php?$1 [L,QSA]
+
+
 SNIPPET;
-                               }
+                               if (empty($rules['apache'][$htaccess])) $rules['apache'][$htaccess] = $content;
+                               else $rules['apache'][$htaccess] .= $content;
                        }
                }