diff --git a/application/Espo/EntryPoints/Portal.php b/application/Espo/EntryPoints/Portal.php index 91a188322e..5f5102c47a 100644 --- a/application/Espo/EntryPoints/Portal.php +++ b/application/Espo/EntryPoints/Portal.php @@ -44,9 +44,14 @@ class Portal extends \Espo\Core\EntryPoints\Base } else if (!empty($data['id'])) { $id = $data['id']; } else { - $url = !empty($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['REQUEST_URI']; - + $url = $_SERVER['REQUEST_URI']; $id = explode('/', $url)[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1]; + + if (!isset($id)) { + $url = $_SERVER['REDIRECT_URL']; + $id = explode('/', $url)[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1]; + } + if (!$id) { $id = $this->getConfig()->get('defaultPortalId'); } diff --git a/portal/index.php b/portal/index.php index f3d606aa52..9b3690446e 100644 --- a/portal/index.php +++ b/portal/index.php @@ -34,7 +34,13 @@ if (!$app->isInstalled()) { exit; } -$url = !empty($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['REQUEST_URI']; +$url = $_SERVER['REQUEST_URI']; +$portalId = explode('/', $url)[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1]; + +if (!isset($portalId)) { + $url = $_SERVER['REDIRECT_URL']; + $portalId = explode('/', $url)[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1]; +} $a = explode('?', $url); if (substr($a[0], -1) !== '/') { @@ -46,7 +52,6 @@ if (substr($a[0], -1) !== '/') { exit(); } -$portalId = explode('/', $url)[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1]; if ($portalId) { $app->setBasePath('../../'); } else {