Add system config htaccess.IgnoreFrontController for prettyURLs w/o mod_env

Added the system config which sets all conditions to true that query the
FrontControllerActive mod_env variable.

Signed-off-by: Felix A. Epp <work@felixepp.de>
This commit is contained in:
Felix Epp 2016-10-01 12:17:55 +02:00 committed by Felix A. Epp
parent 50929751b0
commit 1614b310ef
6 changed files with 36 additions and 12 deletions

View File

@ -9,7 +9,7 @@
* consider important for your instance to your working ``config.php``, and
* apply configuration options that are pertinent for your instance.
*
* This file is used to generate the configuration documentation.
* This file is used to generate the configuration documentation.
* Please consider following requirements of the current parser:
* * all comments need to start with `/**` and end with ` *\/` - each on their
* own line
@ -407,6 +407,17 @@ $CONFIG = array(
*/
'htaccess.RewriteBase' => '/',
/**
* For server setups, that don't have `mod_env` enabled or restricted (e.g. suEXEC)
* this parameter has to be set to true and will assume mod_rewrite.
*
* Please check, if `mod_rewrite` is active and functional before setting this
* parameter and you updated your .htaccess with `occ maintenance:update:htaccess`.
* Otherwise your nextcloud installation might not be reachable anymore.
* For example, try accessing resources by leaving out `index.php` in the URL.
*/
'htaccess.IgnoreFrontController' => false,
/**
* The URL of your proxy server, for example ``proxy.example.com:8081``.
*/
@ -852,9 +863,9 @@ $CONFIG = array(
/**
* Enable maintenance mode to disable Nextcloud
*
* If you want to prevent users from logging in to Nextcloud before you start
* doing some maintenance work, you need to set the value of the maintenance
* parameter to true. Please keep in mind that users who are already logged-in
* If you want to prevent users from logging in to Nextcloud before you start
* doing some maintenance work, you need to set the value of the maintenance
* parameter to true. Please keep in mind that users who are already logged-in
* are kicked out of Nextcloud instantly.
*/
'maintenance' => false,
@ -1172,7 +1183,7 @@ $CONFIG = array(
/**
* Specifies how often the local filesystem (the Nextcloud data/ directory, and
* NFS mounts in data/) is checked for changes made outside Nextcloud. This
* NFS mounts in data/) is checked for changes made outside Nextcloud. This
* does not apply to external storages.
*
* 0 -> Never check the filesystem for outside changes, provides a performance
@ -1212,7 +1223,7 @@ $CONFIG = array(
/**
* List of trusted proxy servers
*
*
* If you configure these also consider setting `forwarded_for_headers` which
* otherwise defaults to `HTTP_X_FORWARDED_FOR` (the `X-Forwarded-For` header).
*/

View File

@ -4,6 +4,7 @@
*
* @author Bart Visscher <bartv@thisnet.nl>
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @author Felix Anand Epp <work@felixepp.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@statuscode.ch>
@ -71,7 +72,7 @@ class Router implements IRouter {
public function __construct(ILogger $logger) {
$this->logger = $logger;
$baseUrl = \OC::$WEBROOT;
if(!(getenv('front_controller_active') === 'true')) {
if(!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
$baseUrl = \OC::$server->getURLGenerator()->linkTo('', 'index.php');
}
if (!\OC::$CLI) {

View File

@ -189,7 +189,7 @@ class JSConfigHelper {
'versionstring' => \OC_Util::getVersionString(),
'enable_avatars' => $this->config->getSystemValue('enable_avatars', true) === true,
'lost_password_link'=> $this->config->getSystemValue('lost_password_link', null),
'modRewriteWorking' => (getenv('front_controller_active') === 'true'),
'modRewriteWorking' => (\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'),
]),
"oc_appconfig" => json_encode([
'core' => [

View File

@ -3,6 +3,7 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bart Visscher <bartv@thisnet.nl>
* @author Felix Anand Epp <work@felixepp.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@statuscode.ch>
@ -93,7 +94,7 @@ class URLGenerator implements IURLGenerator {
* Returns a url to the given app and file.
*/
public function linkTo( $app, $file, $args = array() ) {
$frontControllerActive = (getenv('front_controller_active') === 'true');
$frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
if( $app != '' ) {
$app_path = \OC_App::getAppPath($app);

View File

@ -14,6 +14,7 @@
* @author Christoph Wurst <christoph@owncloud.com>
* @author Clark Tomlinson <fallen013@gmail.com>
* @author cmeh <cmeh@users.noreply.github.com>
* @author Felix Anand Epp <work@felixepp.de>
* @author Florin Peter <github@florin-peter.de>
* @author Frank Karlitschek <frank@karlitschek.de>
* @author Georg Ehrke <georg@owncloud.com>
@ -524,7 +525,7 @@ class OC_Util {
*
* @param string $application application id
* @param string $languageCode language code, defaults to the current language
* @param bool $prepend prepend the Script to the beginning of the list
* @param bool $prepend prepend the Script to the beginning of the list
*/
public static function addTranslations($application, $languageCode = null, $prepend = false) {
if (is_null($languageCode)) {
@ -569,7 +570,7 @@ class OC_Util {
*
* @param string $application application id
* @param bool $prepend prepend the file to the beginning of the list
* @param string $path
* @param string $path
* @param string $type (script or style)
* @return void
*/
@ -1076,7 +1077,7 @@ class OC_Util {
}
}
if(getenv('front_controller_active') === 'true') {
if(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true') {
$location = $urlGenerator->getAbsoluteURL('/apps/' . $appId . '/');
} else {
$location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/');

View File

@ -350,6 +350,7 @@ class UtilTest extends \Test\TestCase {
public function testGetDefaultPageUrlWithRedirectUrlWithoutFrontController() {
putenv('front_controller_active=false');
\OC::$server->getConfig()->deleteSystemValue('htaccess.IgnoreFrontController');
$_REQUEST['redirect_url'] = 'myRedirectUrl.com';
$this->assertSame('http://localhost'.\OC::$WEBROOT.'/myRedirectUrl.com', OC_Util::getDefaultPageUrl());
@ -357,6 +358,7 @@ class UtilTest extends \Test\TestCase {
public function testGetDefaultPageUrlWithRedirectUrlRedirectBypassWithoutFrontController() {
putenv('front_controller_active=false');
\OC::$server->getConfig()->deleteSystemValue('htaccess.IgnoreFrontController');
$_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
$this->assertSame('http://localhost'.\OC::$WEBROOT.'/index.php/apps/files/', OC_Util::getDefaultPageUrl());
@ -368,6 +370,14 @@ class UtilTest extends \Test\TestCase {
$this->assertSame('http://localhost'.\OC::$WEBROOT.'/apps/files/', OC_Util::getDefaultPageUrl());
}
public function testGetDefaultPageUrlWithRedirectUrlWithIgnoreFrontController() {
putenv('front_controller_active=false');
\OC::$server->getConfig()->setSystemValue('htaccess.IgnoreFrontController', true);
$_REQUEST['redirect_url'] = 'myRedirectUrl.com@foo.com:a';
$this->assertSame('http://localhost'.\OC::$WEBROOT.'/apps/files/', OC_Util::getDefaultPageUrl());
}
/**
* Test needUpgrade() when the core version is increased
*/