I have a Laravel 8 project. Everything work fine except the code below
Route::get('/', function ()
{
return redirect('/login');
});
Those code only run when i clear the route cache with php artisan route:clear
or it will return this error everytime after i cache route:
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: HEAD.
I want my users can go to login page despite of they access the http://localhost/myproject/public/
or http://localhost/myproject/public/login
If anyone have the answer, pleas help me. Thank you! enter image description here
CodePudding user response:
use Illuminate\Support\Facades\Route;
Route::get('/greeting', function () { return 'Hello World'; });
CodePudding user response:
You must create before your / route a
Route::get('/login', [\App\Http\Controllers\Auth\LoginController::class, 'login']);
Route::get('/', function() {
return redirect('/login');
});