From 002e7197890221d9a24dc987f7a02a958bf3e4c7 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 1 Dec 2015 18:55:18 +0100 Subject: [PATCH 1/5] Set "SetEnv" within base `.htaccess` file mod_rewrite as used by the front controller may require a `RewriteBase` in case the installation is done using an alias. Since we cannot enforce a writable `.htaccess` file this will move the `front_controller_active` environment variable into the main .htaccess file. If administrators decide to have this one not writable they can still enable this feature by setting the `front_controller_active` environment variable within the Apache config. --- .htaccess | 25 ++++++++++++------------- lib/private/setup.php | 3 +++ version.php | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.htaccess b/.htaccess index 5c11eff9f37..d82cb8ade17 100644 --- a/.htaccess +++ b/.htaccess @@ -44,19 +44,18 @@ RewriteRule ^(build|tests|config|lib|3rdparty|templates)/.* - [R=404,L] RewriteRule ^(\.|autotest|occ|issue|indie|db_|console).* - [R=404,L] - - SetEnv front_controller_active true - RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1] - RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1] - RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff)$ - RewriteCond %{REQUEST_FILENAME} !/remote.php - RewriteCond %{REQUEST_FILENAME} !/public.php - RewriteCond %{REQUEST_FILENAME} !/cron.php - RewriteCond %{REQUEST_FILENAME} !/status.php - RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php - RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php - RewriteRule .* index.php [PT,E=PATH_INFO:$1] - + # Rewrite rules for `front_controller_active` + RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1] + RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1] + RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff)$ + RewriteCond %{REQUEST_FILENAME} !/remote.php + RewriteCond %{REQUEST_FILENAME} !/public.php + RewriteCond %{REQUEST_FILENAME} !/cron.php + RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php + RewriteCond %{REQUEST_FILENAME} !/status.php + RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php + RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php + RewriteRule .* index.php [PT,E=PATH_INFO:$1] diff --git a/lib/private/setup.php b/lib/private/setup.php index 1f91240e9da..4a4b935df03 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -436,6 +436,9 @@ class Setup { // Add rewrite base $content.="\n"; $content.="\n RewriteBase ".\OC::$WEBROOT; + $content .= "\n "; + $content .= "\n SetEnv front_controller_active true"; + $content.="\n "; $content.="\n"; if ($content !== '') { diff --git a/version.php b/version.php index 68ed5c9c217..ca90fdb3167 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ // We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel // when updating major/minor version number. -$OC_Version = array(9, 0, 0, 4); +$OC_Version = array(9, 0, 0, 5); // The human readable string $OC_VersionString = '9.0 pre alpha'; From f87dca95f162e66347fced32e7c333409b0e9012 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 1 Dec 2015 19:55:16 +0100 Subject: [PATCH 2/5] Disable MultiView + DirectorySlash Required for routes that might otherwise collide with existing folders on the system --- .htaccess | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.htaccess b/.htaccess index d82cb8ade17..5401320d577 100644 --- a/.htaccess +++ b/.htaccess @@ -45,6 +45,11 @@ RewriteRule ^(\.|autotest|occ|issue|indie|db_|console).* - [R=404,L] # Rewrite rules for `front_controller_active` + SetEnv front_controller_active true + Options -MultiViews + + DirectorySlash off + RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1] RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1] RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff)$ @@ -56,7 +61,6 @@ RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php RewriteRule .* index.php [PT,E=PATH_INFO:$1] - AddType image/svg+xml svg svgz From a936107c5c6c514de38903c42dd09f3d6267524b Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 1 Dec 2015 20:08:07 +0100 Subject: [PATCH 3/5] Append PATH_INFO to ensure that file can be loaded on update --- .htaccess | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.htaccess b/.htaccess index 5401320d577..aabdafa0db4 100644 --- a/.htaccess +++ b/.htaccess @@ -45,13 +45,12 @@ RewriteRule ^(\.|autotest|occ|issue|indie|db_|console).* - [R=404,L] # Rewrite rules for `front_controller_active` - SetEnv front_controller_active true Options -MultiViews DirectorySlash off - RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1] - RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1] + 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)$ RewriteCond %{REQUEST_FILENAME} !/remote.php RewriteCond %{REQUEST_FILENAME} !/public.php From 6a067b1ec91ad6fcbb5ca2d9fcbe1f2786a75e07 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Tue, 1 Dec 2015 22:03:25 +0100 Subject: [PATCH 4/5] Set RewriteBase to / if OC::WEBROOT is not set --- lib/private/setup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/setup.php b/lib/private/setup.php index 4a4b935df03..2c959622cc7 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -434,8 +434,9 @@ class Setup { } // Add rewrite base + $webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/'; $content.="\n"; - $content.="\n RewriteBase ".\OC::$WEBROOT; + $content.="\n RewriteBase ".$webRoot; $content .= "\n "; $content .= "\n SetEnv front_controller_active true"; $content.="\n "; From 65b4d97a2aabbb9d1ecb68b0d0021b7af0b99659 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 2 Dec 2015 10:51:52 +0100 Subject: [PATCH 5/5] fix indentation --- .htaccess | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.htaccess b/.htaccess index aabdafa0db4..4f2a6f35af4 100644 --- a/.htaccess +++ b/.htaccess @@ -45,10 +45,10 @@ RewriteRule ^(\.|autotest|occ|issue|indie|db_|console).* - [R=404,L] # Rewrite rules for `front_controller_active` - Options -MultiViews - - DirectorySlash off - + Options -MultiViews + + DirectorySlash off + 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)$