php - Redirect to route without get params with Laravel -


i have legacy urls params want redirect route without these parameters.

in web.php have:

route::get('/', ['as' => 'welcome', 'uses' => 'pagecontroller@welcome']); 

urls http://example.com/?page_id=5 should redirect (302) http://example.com/.

in controller tried following:

public function welcome(request $request) {     if($request->has('page_id')) {          redirect()->to('welcome', 302);     }      return view('welcome'); } 

it reaches redirect the url still has ?page_id=5 in it. like:

redirect()->to('welcome', 302)->with('page_id', null); 

made no difference well. best way in laravel 5.3 redirect page parameters after ? 1 without parameters?

you should use return in front of redirect() method make work:

public function welcome(request $request) {     if($request->has('page_id')) {          return redirect()->route('welcome');     }      return view('welcome'); } 

hope helps!


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -