public function redirectForTrailingSlash()
    {
        $config = \Nf\Registry::get('config');
        $redirectionUrl = false;
        $requestParams = '';
        $requestPage = '/' . $this->_uri;
        
        // we don't redirect for the home page...
        if ($requestPage != '/' && mb_strpos($requestPage, '/?') !== 0) {
            // the url without the params is :
            if (mb_strpos($requestPage, '?') !== false) {
                $requestParams = mb_substr($requestPage, mb_strpos($requestPage, '?'), mb_strlen($requestPage) - mb_strpos($requestPage, '?'));
                $requestPage = mb_substr($requestPage, 0, mb_strpos($requestPage, '?'));
            }
            
            if (isset($config->trailingSlash->needed) && $config->trailingSlash->needed == true) {
                if (mb_substr($requestPage, - 1, 1) != '/') {
                    $redirectionUrl = 'http://' . $_SERVER['HTTP_HOST'] . $requestPage . '/' . $requestParams;
                }
            } else {
                if (mb_substr($requestPage, - 1, 1) == '/') {
                    $redirectionUrl = 'http://' . $_SERVER['HTTP_HOST'] . rtrim($requestPage, '/') . $requestParams;
                }
            }
            
            if ($redirectionUrl !== false) {
                $response = new \Nf\Front\Response\Http();
                $response->redirect($redirectionUrl, 301);
                $response->sendHeaders();
                return true;
            }
        }
        
        return false;
    }
public function redirectForTrailingSlash()
    {
        $config = \Nf\Registry::get('config');
        $redirectionUrl = false;
        $requestParams = '';
        $requestPage = '/' . $this->_uri;
        
        // we don't redirect for the home page...
        if ($requestPage != '/' && mb_strpos($requestPage, '/?') !== 0) {
            // the url without the params is :
            if (mb_strpos($requestPage, '?') !== false) {
                $requestParams = mb_substr($requestPage, mb_strpos($requestPage, '?'), mb_strlen($requestPage) - mb_strpos($requestPage, '?'));
                $requestPage = mb_substr($requestPage, 0, mb_strpos($requestPage, '?'));
            }
            
            if (isset($config->trailingSlash->needed) && $config->trailingSlash->needed == true) {
                if (mb_substr($requestPage, - 1, 1) != '/') {
                    $redirectionUrl = 'http://' . $_SERVER['HTTP_HOST'] . $requestPage . '/' . $requestParams;
                }
            } else {
                if (mb_substr($requestPage, - 1, 1) == '/') {
                    $redirectionUrl = 'http://' . $_SERVER['HTTP_HOST'] . rtrim($requestPage, '/') . $requestParams;
                }
            }
            
            if ($redirectionUrl !== false) {
                $response = new \Nf\Front\Response\Http();
                $response->redirect($redirectionUrl, 301);
                $response->sendHeaders();
                return true;
            }
        }
        
        return false;
    }
public function redirectForTrailingSlash ( ) { $ config = \ Nf \ Registry :: get ( 'config' ) ; $ redirectionUrl = false ; $ requestParams = '' ; $ requestPage = '/' . $ this -> _uri ; // we don't redirect for the home page... if ( $ requestPage != '/' && mb_strpos ( $ requestPage , '/?' ) !== 0 ) { // the url without the params is : if ( mb_strpos ( $ requestPage , '?' ) !== false ) { $ requestParams = mb_substr ( $ requestPage , mb_strpos ( $ requestPage , '?' ) , mb_strlen ( $ requestPage ) - mb_strpos ( $ requestPage , '?' ) ) ; $ requestPage = mb_substr ( $ requestPage , 0 , mb_strpos ( $ requestPage , '?' ) ) ; } if ( isset ( $ config -> trailingSlash -> needed ) && $ config -> trailingSlash -> needed == true ) { if ( mb_substr ( $ requestPage , - 1 , 1 ) != '/' ) { $ redirectionUrl = 'http://' . $ _SERVER [ 'HTTP_HOST' ] . $ requestPage . '/' . $ requestParams ; } } else { if ( mb_substr ( $ requestPage , - 1 , 1 ) == '/' ) { $ redirectionUrl = 'http://' . $ _SERVER [ 'HTTP_HOST' ] . rtrim ( $ requestPage , '/' ) . $ requestParams ; } } if ( $ redirectionUrl !== false ) { $ response = new \ Nf \ Front \ Response \ Http ( ) ; $ response -> redirect ( $ redirectionUrl , 301 ) ; $ response -> sendHeaders ( ) ; return true ; } } return false ; }
handle the redirection according to the trailing slash configuration
handle the redirection according to the trailing slash configuration