From b315a5ee29b346b7f6bcc7b56d5f369fac8bdec9 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 9 Mar 2016 15:13:07 +0100 Subject: [PATCH 1/2] Add base rewrite rule only when RewriteBase is defined In case Apache is configured with an `Alias` such as with the ownCloud packages the rewrite rules will fail when no valid RewriteBase is configured. --- .htaccess | 1 - lib/private/setup.php | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.htaccess b/.htaccess index ec33fe31e1..085467e91c 100644 --- a/.htaccess +++ b/.htaccess @@ -65,7 +65,6 @@ RewriteCond %{REQUEST_FILENAME} !/updater/ RewriteCond %{REQUEST_FILENAME} !/ocs-provider/ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.* - RewriteRule .* index.php [PT,E=PATH_INFO:$1] AddType image/svg+xml svg svgz diff --git a/lib/private/setup.php b/lib/private/setup.php index b9f8828227..8a10a9cfbe 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -422,8 +422,9 @@ class Setup { // Add rewrite base $webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/'; - $content.="\n"; - $content.="\n RewriteBase ".$webRoot; + $content .= "\n"; + $content .= "\n RewriteRule .* index.php [PT,E=PATH_INFO:$1]"; + $content .= "\n RewriteBase ".$webRoot; $content .= "\n "; $content .= "\n SetEnv front_controller_active true"; $content .= "\n "; From bd17cc793c48629ebc8a3ef0084d7acff6077460 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Thu, 10 Mar 2016 22:18:53 +0100 Subject: [PATCH 2/2] Improved rewrite rule As per https://github.com/owncloud/core/issues/23098 and https://github.com/owncloud/core/issues/23117 --- lib/private/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/setup.php b/lib/private/setup.php index 8a10a9cfbe..5988a0b2d1 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -423,7 +423,7 @@ class Setup { // Add rewrite base $webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/'; $content .= "\n"; - $content .= "\n RewriteRule .* index.php [PT,E=PATH_INFO:$1]"; + $content .= "\n RewriteRule . index.php [PT,E=PATH_INFO:$1]"; $content .= "\n RewriteBase ".$webRoot; $content .= "\n "; $content .= "\n SetEnv front_controller_active true";