我可以在 Laravel 上正常使用 Route::get('/') 吗?



我有一个Laravel 8项目。除了

下面的代码外,一切正常
Route::get('/', function ()
{
return redirect('/login');
});

这些代码只在我使用php artisan route:clear清除路由缓存时运行,否则每次在i缓存路由后都会返回此错误:

SymfonyComponentHttpKernelExceptionMethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: HEAD.

我希望我的用户可以进入登录页面,尽管他们访问http://localhost/myproject/public/http://localhost/myproject/public/login

如果有人知道答案,请帮助我。谢谢你!输入图片描述

1。将此添加到web.phpuse IlluminateSupportFacadesRoute;

的顶部2。

Route::get('/greeting', function () {
return 'Hello World';
});
路由Laravel

最新更新