[英]Laravel: Custom login path doesn't work
I set my login path to be 123. Here's how I did it: 我将登录路径设置为123。这是我的操作方式:
In routes/web.php
, I posted this: 在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');
I deleted the default Auth::routes();
我删除了默认的Auth::routes();
line in the same file. 在同一文件中。
Like it should, localhost:8000/login
generates this error: 像它应该的那样, localhost:8000/login
生成此错误:
NotFoundHttpException in RouteCollection.php line 161:
But, when I type localhost:8000/123
, I get: 但是,当我键入localhost:8000/123
,我得到:
ReflectionException in RouteSignatureParameters.php line 39:
Method App\Http\Controllers\HomeController::index() does not exist
after getting redirected to localhost:8000/home
. 重定向到localhost:8000/home
。
So there is some sort of weird redirect going on here. 因此,这里发生了某种奇怪的重定向。 /home doesn't exist, so probably that is the direct reason for the error. / home不存在,所以可能是错误的直接原因。 But why does it redirect at all? 但是为什么它完全重定向? It should go to the login page! 它应该去登录页面!
Help please. 请帮助。
It looks like you have cached routes to me. 看来您已缓存到我的路线。
php artisan cache:clear
php artisan route:cache
Should remove any cached routes created by the Auth::routes();
应该删除由Auth::routes();
创建的所有缓存路由Auth::routes();
function. 功能。
The redirect takes place because of a setting in Http/Controllers/Auth/LoginController
重定向的发生是由于Http/Controllers/Auth/LoginController
protected $redirectTo = '/home';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.