Welcome Guest, Not a member yet? Register   Sign In
redirect()->to (multidomain website)
#1

Hi,
for multidomain website redirect()->to() doesn't work properly and redirects to main domain, instead of redirecting to relative URL
Code:
    public function to(string $uri, ?int $code = null, string $method = 'auto')
    {
        // If it appears to be a relative URL, then convert to full URL
        // for better security.
        if (strpos($uri, 'http') !== 0) {
            $uri = site_url($uri);
        }

        return $this->redirect($uri, $method, $code);
    }
I would suggest adding another parameter to this function to override security measure and redirect to relative URLs or use domain under which controller works.

Best regards,
Gregor
Reply
#2

You can create the uri yourself and pass it to the redirect()->to($subdomainTo) method with the exact address
Reply
#3

The entire HTTP layer is built around certain assumptions of the “current URL” corresponding somewhat to the configuration in Config\App. It’s actually a somewhat tricky business to discern what is typed into the browser location bar. Multidomain support is definitely an area the framework could do better, but I think it needs to happen at a deeper configuration level so that URL Helper functions don’t need to know/care about single/multi domains.
Reply
#4

See https://codeigniter4.github.io/userguide...in-support
Reply
#5

@kenjis, Thank you.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB