Route::get('testRedirect', 'UserController@testRedirect'); 示例动作controller: public function testRedirect() { // 以下示例代码放在这个地方 } 1. 简单的重定向 假设我们当前的域名为:http://localhost return redirect('home'); 重定向到 http://localhost/home return redirect('auth/login'); 重定向...
Route::get('home','HomeController@index')->name('home'); If you have anamed route, you can easily create aredirect, like so: returnredirect()->route('home'); Now, if you ever change the home route to go to the/page instead of the/homeURL, you can update the route: ...
Route::group(['prefix'=>'admin','namespace'=>'admin\student'],function(){Route::get('/student/{bar?}',['as'=>'student','middleware'=>'auth','uses'=>'StudentController@index']);Route::get('/stdent/{user_id}',function($user_id){return'student'.$user_id;})->where('user','...
重定向响应是Illuminate\Http\RedirectResponse类的实例,其中包含了必须的头信息将用户重定向到另一个URL。辅助函数redirect返回的就是RedirectResponse类的实例。 示例路由: Route::get('testRedirect','UserController@testRedirect'); 示例动作: publicfunctiontestRedirect(){// 以下示例代码为此处实现} 1|0简单的重...
2.后端# // 后端跳转 类似前端a链接 跳转returnredirect()->to('/save');returnredirect()->action('SiteController@save');returnredirect()->route('save');returnback();// 跳转到上一页 同样,第三种命名的方法,路由方法名改变,不影响程序跳转。
-> route(“重定向到路由的别名当中”) redirect() -> back(“返回上一层请求的地址”) redirect(...
重定向URL 路由: Route::get('itsolutionstuff/tags', 'HomeController@tags'); 控制器: public function home() { return redirect('itsolutionstuff/tags'); } 重定向回上一页 public function home() {...
returnredirect()->action('HomeController@index'); If your controller route requires parameters, you may pass them as the second argument to theactionmethod: returnredirect()->action('UserController@profile',['id'=>1]); Redirecting With Flashed Session Data# ...
Route::any('foo',function() { return'Hello World'; }); 仅支持HTTPS的路由 Route::get('foo',array('https',function() { return'Must be over HTTPS'; })); 实际开发中经常需要根据路由生成 URL,URL::to方法就可以满足此需求: $url=URL::to('foo'); ...
If your controller route requires parameters, you may pass them as the second argument to theactionmethod: returnredirect()->action( 'UserController@profile', ['id'=>1] ); Redirecting With Flashed Session Data Redirecting to a new URL andflashing data to the sessionare usually done at the ...