当我尝试重定向到 laravel 5.6 中的另一个页面时,出现类似 "Sorry, the page you are looking for could not be found." 的错误
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');
玩得开心:)
提前感谢您查看我的问题
我正在研究 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');
玩得开心:)