Laravel 5.2-每条路线都重定向到首页 [英] Laravel 5.2 - Every route redirects to the homepage

查看:106
本文介绍了Laravel 5.2-每条路线都重定向到首页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚启动了laravel 5.2应用程序.我选择的每条路线(/注册,/登出,登录等)都会将我重定向到首页.

I just started an laravel 5.2 application. Every route I take (/register, /logout, login,...) redirects me to the homepage.

这是我的路线

<?php
Route::group(['middleware' => ['web']], function () {
//Register
    Route::get('/register', 'Auth\AuthController@getRegister');
    Route::get('/register/success', 'Auth\AuthController@getRegisterSuccess');

    Route::post('/register', 'Auth\AuthController@PostRegister');

//Login
    Route::get('/login', 'Auth\AuthController@getLogin');

    Route::post('/login', 'Auth\AuthController@PostLogin');

//Password Reset
    Route::get('/password/reset/email', 'Auth\PasswordController@getEmail');
    Route::get('/password/reset/{token}', 'Auth\PasswordController@getToken');
    Route::get('/password/reset/sent', 'Auth\PasswordController@getSent');

    Route::post('/password/reset/email', 'Auth\PasswordController@postEmail');
    Route::post('/password/reset', 'Auth\PasswordController@postReset');
});


Route::group(['middleware' => ['web', 'auth']], function () {
    Route::get('/logout', 'Auth\AuthController@getLogout');
});

Route::get('/', function () {
    return view('welcome');
});

当我删除Route::group(['middleware' => ['web']], function () {行时,我可以访问该页面,但这给了我

when I remove the Route::group(['middleware' => ['web']], function () { line I can access the page but it gives me the error of

未定义变量:错误

Undefined variable: errors

这就是为什么需要Web中间件的原因,所以我有点受阻.

That's why the web middelware is required, So I'm kinda stuck.

控制器和视图正常工作.只是这种重定向,我不知道.

The controller and views work. It's just this redirect that I can't figure out.

感谢您的帮助!

推荐答案

您需要在AuthController中进行更改,然后将您要重定向到的位置.

You need to make changes in your AuthController and put where do you want to be redirected.

然后您需要将其添加到您拥有的每个控制器中:

Then you need to add this in every controller you have:

public function __construct() { $this->middleware('auth'); }

这篇关于Laravel 5.2-每条路线都重定向到首页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆