簡體   English   中英

當我嘗試重定向到laravel 5.6中的另一個頁面時,出現類似“抱歉,找不到您要搜索的頁面”的錯誤。

[英]when i am try to redirect to another page in laravel 5.6 then getting error like “Sorry, the page you are looking for could not be found.”

感謝提前查看我的問題

我正在研究laravel 5.6。 我用if語句做條件

喜歡

if($value == 5){
   return redirect('Mycon/Home');
}else{
//some thing
}

我也使用Illuminate \\ Support \\ Facades \\ Redirect; 在控制器文件上。 我的條件正常工作,並且也重定向到正確的URL,這意味着http:// localhost / sample / test / Mycon / Home。但是,重定向URL正確之后,卻顯示錯誤,如對不起,找不到您要查找的頁面。

我也在路由文件中添加功能,如Route :: get('/ Home','Mycon @ Home');

如果您注冊了路線:

Route::get('/Home', 'Mycon@Home');

您應該這樣重定向:

return redirect('Home');

第一個參數是url,第二個參數是操作,如果要通過操作執行此操作,則應這樣重定向:

return redirect()->action('Mycon@Home);

您的路由與重定向路由不同:

if($value == 5){
   return redirect('Mycon/Home');
}else{
//some thing
}

路線應類似於:

Route::get('/Mycon/Home', 'Mycon@Home');

我將建議以下示例:

路線

Route::get('mycon/home', 'MyController@showHome')->name('home');

重定向

return redirect()->route('home');

玩得開心 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM