OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery PHP Method

getSelfRoutedURLNoQuery() public static method

Returns the routed URL of the current host + current view.
public static getSelfRoutedURLNoQuery ( ) : string
return string
    public static function getSelfRoutedURLNoQuery()
    {
        $selfURLhost = self::getSelfURLhost();
        $route = '';
        if (!empty($_SERVER['REQUEST_URI'])) {
            $route = $_SERVER['REQUEST_URI'];
            if (!empty($_SERVER['QUERY_STRING'])) {
                $route = str_replace($_SERVER['QUERY_STRING'], '', $route);
                if (substr($route, -1) == '?') {
                    $route = substr($route, 0, -1);
                }
            }
        }
        $infoWithBaseURLPath = self::buildWithBaseURLPath($route);
        if (!empty($infoWithBaseURLPath)) {
            $route = $infoWithBaseURLPath;
        }
        $selfRoutedURLNoQuery = $selfURLhost . $route;
        return $selfRoutedURLNoQuery;
    }

Usage Example

Example #1
0
 /**
  * Obtains the SSO URL containing the AuthRequest
  * message deflated.
  *
  * @param OneLogin_Saml2_Settings $settings Settings
  */
 public function getRedirectUrl($returnTo = null)
 {
     $settings = $this->auth->getSettings();
     $authnRequest = new OneLogin_Saml2_AuthnRequest($settings);
     $parameters = array('SAMLRequest' => $authnRequest->getRequest());
     if (!empty($returnTo)) {
         $parameters['RelayState'] = $returnTo;
     } else {
         $parameters['RelayState'] = OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery();
     }
     $url = OneLogin_Saml2_Utils::redirect($this->auth->getSSOurl(), $parameters, true);
     return $url;
 }
All Usage Examples Of OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery