Support the ongoing development of Laravel.io →
posted 9 years ago
Requests

Hey, i made a search view that searches data from the get method and tried to redirect the user back home if nothing is in the get method.

I used this

 if(!isset($target)) {
 	Header('Location: '.URL::route('home'));
 }

It did not work. I also used

 if(!isset($target)) {
 	Redirect::to('/');
 }

or

 if(empty($target)) {
 	Redirect::to('/');
 }

And it still does not work. If i do

 if(empty($target)) {
 	echo "test";
 }

test is echoed, but the redirect does not work. Why?

Last updated 2 years ago.
0

Try this instead. :)

return Redirect::to('/');

Add the return statement.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Joe96 joe96 Joined 28 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.