Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rapido's avatar

Redirecting to an external URL from a POST request

Hi everyone,

I'm trying redirect my users to an external URL after a form submission in a POST request.

public function store(Request $request) { return redirect()->away("https://google.com"); }

When I submit the form, nothing happens. The form is still displayed. But if I insert dd() to check if my routing is correct, a blank page shows up as expected.

public function store(Request $request) { dd(); return redirect()->away("https://google.com"); }

Any idea of what I've done wrong ?

Thanks !

0 likes
7 replies
rapido's avatar

Thanks for your answer.

So I tried your route and it works if I go to this url from my browser

Route::get('testing123', function() {
    return redirect()->away('https://www.google.com');
});

But if I set your suggested route as action destination of my form it doesn't work, both in POST or GET method.

<form action="{{ url('/testing123') }}" method="post">
	@csrf
	<button type="submit">Submit</button>
</form>

Any idea ?

fylzero's avatar

@rapido Posting to a get route isn't going to work. You'd have to change the route to use Route::post for this to work.

1 like
rapido's avatar

Yes I changed to route to post when testing with the form. Sorry for the confusion

neilstee's avatar

@rapido your original post looks good and should work fine.

As @fylzero mention, there might be somewhere in your code that is messing up the redirect.

Also, are you for some reason using Livewire? If so, there is some issue on redirect when using Laravel with Livewire. Check out the link below and see if the answers there can solve your problem including using of $this->redirect('/url'); without a return.

Source: https://github.com/livewire/livewire/issues/1110

rapido's avatar

Not using livewire.

I finally found a workaround for my problem without having to redirect.

Thanks everyone for your answers.

neilstee's avatar

Well it might be a good idea to share it so others can find it useful as well 😉

Please or to participate in this conversation.