diff --git a/modules/setup/application/clicommands/ConfigCommand.php b/modules/setup/application/clicommands/ConfigCommand.php index 0bf0313c3..04b518b07 100644 --- a/modules/setup/application/clicommands/ConfigCommand.php +++ b/modules/setup/application/clicommands/ConfigCommand.php @@ -110,8 +110,9 @@ class ConfigCommand extends Command 'The argument --root/--document-root expects a directory from which the webserver will serve files' )); } - $webserver->setWebPath($path); - $webserver->setDocumentRoot($documentRoot); + $webserver + ->setDocumentRoot($documentRoot) + ->setWebPath($path); $config = $webserver->generate() . "\n"; if (($file = $this->params->get('file')) !== null) { if (file_exists($file) === true) { diff --git a/modules/setup/library/Setup/Webserver.php b/modules/setup/library/Setup/Webserver.php index 5cffe349c..d8c18161c 100644 --- a/modules/setup/library/Setup/Webserver.php +++ b/modules/setup/library/Setup/Webserver.php @@ -75,17 +75,20 @@ abstract class Webserver abstract protected function getTemplate(); /** - * Setter for web path + * Set the URL path of Icinga Web 2 * - * @param string $webPath + * @param string $urlPath + * + * @return $this */ - public function setWebPath($webPath) + public function setWebPath($urlPath) { - $this->webPath = $webPath; + $this->webPath = '/' . ltrim(trim((string) $urlPath), '/'); + return $this; } /** - * Getter for web path + * Get the URL path of Icinga Web 2 * * @return string */ @@ -103,7 +106,7 @@ abstract class Webserver */ public function setDocumentRoot($documentRoot) { - $this->documentRoot = (string) $documentRoot; + $this->documentRoot = trim((string) $documentRoot); return $this; }