【问题标题】:Redirect a route with parameters in url to another route with these parameters (Laravel)将带有参数的路由重定向到带有这些参数的另一个路由(Laravel)
【发布时间】:2018-10-25 15:22:34
【问题描述】:

我有一个 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。

【问题讨论】:

标签: php laravel laravel-5 laravel-5.5


【解决方案1】:

你应该试试这个方法:

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

【讨论】:

  • @Antonio Morales :很高兴为您提供帮助!!!如果我的回答对你有用,那么请为我的回答投票。
【解决方案2】:

你也可以使用

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

它将重定向到带有输入的路由

【讨论】:

    【解决方案3】:

    使用->with() 您正在刷新会话。 你可以这样做:

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

    【讨论】:

      猜你喜欢
      • 2014-06-10
      • 1970-01-01
      • 2017-12-30
      • 2013-09-14
      • 2016-01-20
      • 2017-10-21
      • 2020-04-22
      • 2017-07-10
      • 2018-08-31
      相关资源
      最近更新 更多