Gustav F N
Gustav F N

Reputation: 9

How to redirect in Laravel to an external website

I redirect the user to another (external) website, but Laravel keeps routing back to my app's URI. My controller code is

public function showClientSite($councilUrl)
{
    //return Redirect::to($councilUrl)
    Redirect::away($councilUrl);
}

what i get is https://www.mywebsite/appname/public/http://www.clientwebsite.co.uk

But i want it to be http://www.clientwebsite.co.uk

Upvotes: 0

Views: 252

Answers (2)

thisisablock
thisisablock

Reputation: 559

That should work.

Try

return Redirect::to('http://google.com');

or

return Redirect::away('http://google.com');

Away adds only Header and https status to response. Does your $councilUrl have an http:// prefix?

Upvotes: 0

Joel Hinz
Joel Hinz

Reputation: 25384

The redirect call in itself doesn't do anything - you need to return it from the function in order for Laravel to actually use it.

return Redirect::away($councilUrl);

Upvotes: 1

Related Questions