重定向到错误的URL Laravel 5.1身份验证

3
我不知道我在这里做错了什么,每当我输入URL:localhost/project/public/auth/login时,它会将我重定向到localhost/project/public/home,因此我会收到错误:NotFoundHttpException
这是我的路由:
// Authentication routes...
Route::get('/auth/login', 'Auth\AuthController@getLogin');
Route::post('/auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');

// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');


Route::controllers([
   'password' => 'Auth\PasswordController',
]);

我已经在authController中添加了这些内容:

protected $redirectPath = "/adminportfolio";
protected $loginPath = 'auth/login';
protected $redirectAfterLogout = '/index';

Please can someone help me out here..


4
您被重定向了,因为您已经登录。但您应该被重定向到/adminportfolio页面。请尝试从$redirectPath中删除前导斜杠/ - BrokenBinary
是的,感谢@BrokenBinary。 - Guest012393
我也遇到过这个问题 :) - MaXi32
1个回答

0

从中间件中找到名为RedirectIfAuthenticated的文件,它看起来像这样:

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Contracts\Auth\Guard;

class RedirectIfAuthenticated
{
    ...
    [----this file was truncated for simplicity----]
    ...

    public function handle($request, Closure $next)
    {
        if ($this->auth->check()) {
            return redirect('/home');
        }

        return $next($request);
    }
}

你会注意到这句话中的redirect('/home'),你可能需要根据自己的需求进行更改。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接