Laravel:自定义登录路径不起作用

时间:2017-03-31 08:55:18

标签: php laravel

我将登录路径设置为123.这是我如何做到的:

routes/web.php中,我发布了这个:

// Authentication Routes...
Route::get('123', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('123', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout')->name('logout');

// Registration Routes...
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'Auth\RegisterController@register');

// Password Reset Routes...
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset');

我删除了同一档案中的默认Auth::routes();行。

就像它应该的那样,localhost:8000/login会产生这个错误:

NotFoundHttpException in RouteCollection.php line 161:

但是,当我输入localhost:8000/123时,我得到:

ReflectionException in RouteSignatureParameters.php line 39:
Method App\Http\Controllers\HomeController::index() does not exist

重定向到localhost:8000/home后。

所以这里有一些奇怪的重定向。 / home不存在,所以可能这是错误的直接原因。但为什么它会重定向呢?它应该进入登录页面!

请帮助。

1 个答案:

答案 0 :(得分:0)

看起来你已经缓存了我的路线。

php artisan cache:clear

php artisan route:cache

应删除Auth::routes();函数创建的所有缓存路由。

由于Http/Controllers/Auth/LoginController

中的设置,重定向发生
 protected $redirectTo = '/home';