src/Control/Middleware/CanonicalURLMiddleware.php
protected function getRedirect(HTTPRequest $request)
    {
        // Check global disable
        if (!$this->isEnabled()) {
            return null;
        }

        // Get properties of current request
        $host = $request->getHost();
        $scheme = $request->getScheme();

        // Check https
        if ($this->requiresSSL($request)) {
            $scheme = 'https';

            // Promote ssl domain if configured
            $host = $this->getForceSSLDomain() ?: $host;
        }

        // Check www.
        if ($this->getForceWWW() && strpos($host, 'www.') !== 0) {
            $host = "www.{$host}";
        }

        // No-op if no changes
        if ($request->getScheme() === $scheme && $request->getHost() === $host) {
            return null;
        }

        return $this->redirectToScheme($request, $scheme, $host);
    }
protected function getRedirect(HTTPRequest $request)
    {
        // Check global disable
        if (!$this->isEnabled()) {
            return null;
        }

        // Get properties of current request
        $host = $request->getHost();
        $scheme = $request->getScheme();

        // Check https
        if ($this->requiresSSL($request)) {
            $scheme = 'https';

            // Promote ssl domain if configured
            $host = $this->getForceSSLDomain() ?: $host;
        }

        // Check www.
        if ($this->getForceWWW() && strpos($host, 'www.') !== 0) {
            $host = "www.{$host}";
        }

        // No-op if no changes
        if ($request->getScheme() === $scheme && $request->getHost() === $host) {
            return null;
        }

        return $this->redirectToScheme($request, $scheme, $host);
    }
protected function getRedirect ( HTTPRequest $ request ) { // Check global disable if ( ! $ this -> isEnabled ( ) ) { return null ; } // Get properties of current request $ host = $ request -> getHost ( ) ; $ scheme = $ request -> getScheme ( ) ; // Check https if ( $ this -> requiresSSL ( $ request ) ) { $ scheme = 'https' ; // Promote ssl domain if configured $ host = $ this -> getForceSSLDomain ( ) ? : $ host ; } // Check www. if ( $ this -> getForceWWW ( ) && strpos ( $ host , 'www.' ) !== 0 ) { $ host = "www.{$host}" ; } // No-op if no changes if ( $ request -> getScheme ( ) === $ scheme && $ request -> getHost ( ) === $ host ) { return null ; } return $ this -> redirectToScheme ( $ request , $ scheme , $ host ) ; }
Given request object determine if we should redirect.

@param HTTPRequest $request Pre-validated request object
@return HTTPResponse|null If a redirect is needed return the response
Given request object determine if we should redirect .