diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-06-24 12:20:22 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-06-24 12:20:22 +0200 |
commit | 300d1c88d09a1dff05e122c4c2e04da47bdb03dc (patch) | |
tree | abb1c0f0e9f598aca696f47149e85e095fa0b3ee /lib | |
parent | 9e93d1ed257c393a0e954fc0ae635474fd1a01e1 (diff) | |
parent | 0db311c9db3b1294625ff06b9cdc6116797bee4b (diff) | |
download | nextcloud-server-300d1c88d09a1dff05e122c4c2e04da47bdb03dc.tar.gz nextcloud-server-300d1c88d09a1dff05e122c4c2e04da47bdb03dc.zip |
Merge pull request #17106 from owncloud/htaccess-update-only-once
Only update the htaccess ErrorDocument links when they are not set yet
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/setup.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/private/setup.php b/lib/private/setup.php index 7ca30e172ec..1ffe074dc34 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -402,10 +402,20 @@ class Setup { throw new \OC\HintException('.htaccess file has the wrong version. Please upload the correct version. Maybe you forgot to replace it after updating?'); } - $content = "\n"; - $content.= "ErrorDocument 403 ".\OC::$WEBROOT."/core/templates/403.php\n";//custom 403 error page - $content.= "ErrorDocument 404 ".\OC::$WEBROOT."/core/templates/404.php";//custom 404 error page - @file_put_contents($setupHelper->pathToHtaccess(), $content, FILE_APPEND); //suppress errors in case we don't have permissions for it + $htaccessContent = file_get_contents($setupHelper->pathToHtaccess()); + $content = ''; + if (strpos($htaccessContent, 'ErrorDocument 403') === false) { + //custom 403 error page + $content.= "\nErrorDocument 403 ".\OC::$WEBROOT."/core/templates/403.php"; + } + if (strpos($htaccessContent, 'ErrorDocument 404') === false) { + //custom 404 error page + $content.= "\nErrorDocument 404 ".\OC::$WEBROOT."/core/templates/404.php"; + } + if ($content !== '') { + //suppress errors in case we don't have permissions for it + @file_put_contents($setupHelper->pathToHtaccess(), $content . "\n", FILE_APPEND); + } } public static function protectDataDirectory() { |