/**
* Retrieve the absolute path of the SimpleSAMLphp installation, relative to the root of the website.
*
* For example: simplesaml/
*
* The path will always end with a '/' and never have a leading slash.
*
* @return string The absolute path relative to the root of the website.
*
* @throws SimpleSAML_Error_Exception If the format of 'baseurlpath' is incorrect.
*/
public function getBaseURL()
{
$baseURL = $this->getString('baseurlpath', 'simplesaml/');
if (preg_match('/^\\*(.*)$/D', $baseURL, $matches)) {
// deprecated behaviour, will be removed in the future
return \SimpleSAML\Utils\HTTP::getFirstPathElement(false) . $matches[1];
}
if (preg_match('#^https?://[^/]*/(.*)$#', $baseURL, $matches)) {
// we have a full url, we need to strip the path
return $matches[1];
} elseif ($baseURL === '' || $baseURL === '/') {
// Root directory of site
return '';
} elseif (preg_match('#^/?([^/]?.*/)#D', $baseURL, $matches)) {
// local path only
return $matches[1];
} else {
// invalid format
throw new SimpleSAML_Error_Exception('Incorrect format for option \'baseurlpath\'. Value is: "' . $this->getString('baseurlpath', 'simplesaml/') . '". Valid format is in the form' . ' [(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/].');
}
}