public function getScriptUrl()
    {
        $server = $this->getServerParams();
        if ($this->_scriptUrl === null) {
            $scriptFile = $this->getScriptFile();
            $scriptName = basename($scriptFile);
            if (isset($server['SCRIPT_NAME']) && basename($server['SCRIPT_NAME']) === $scriptName) {
                $this->_scriptUrl = $server['SCRIPT_NAME'];
            } elseif (isset($server['PHP_SELF']) && basename($server['PHP_SELF']) === $scriptName) {
                $this->_scriptUrl = $server['PHP_SELF'];
            } elseif (isset($server['ORIG_SCRIPT_NAME']) && basename($server['ORIG_SCRIPT_NAME']) === $scriptName) {
                $this->_scriptUrl = $server['ORIG_SCRIPT_NAME'];
            } elseif (isset($server['PHP_SELF']) && ($pos = strpos($server['PHP_SELF'], '/' . $scriptName)) !== false) {
                $this->_scriptUrl = substr($server['SCRIPT_NAME'], 0, $pos) . '/' . $scriptName;
            } elseif (!empty($server['DOCUMENT_ROOT']) && strpos($scriptFile, $server['DOCUMENT_ROOT']) === 0) {
                $this->_scriptUrl = str_replace([$server['DOCUMENT_ROOT'], '\\'], ['', '/'], $scriptFile);
            } else {
                throw new InvalidConfigException('Unable to determine the entry script URL.');
            }
        }

        return $this->_scriptUrl;
    }