将网址中具有参数的路由重定向到具有这些参数的另一条路由(Laravel)

时间:2018-10-25 06:44:07

标签: php laravel laravel-5 laravel-5.5

我有一个url,我想进行重定向,并且想要保留url参数。 我正在使用-> with 方法,但是它不起作用。

示例: http://mywebsite.local/product-name-random?select_article=710

我想将此网址重定向到: http://mywebsite.local/father-category-of-this-product?select_article=710

我正在使用此代码,但是它不起作用:

return redirect()->route('web.custom_url', $father_cathegory->seo->slug)->with('select_article', Input::get('select_article')); 

-> with()无法正常工作。什么都没发生。

我正在使用Laravel 5.5。

3 个答案:

答案 0 :(得分:1)

您应该尝试这种方式:

return Redirect::to('/admin/slider?rdStatus='. $rdStatus);

答案 1 :(得分:0)

您也可以使用

redirect()->route('web.custom_url',[ $father_cathegory->seo->slug])->withInput();

它将使用输入重定向到路由

答案 2 :(得分:0)

使用->with()刷新会话。 您可以执行以下操作:

$to = route('web.custom_url', $father_cathegory->seo->slug) . 
    '?select_article=' . Input::get('select_article');
return redirect()->to($to);
相关问题