Route Prefix and Group Laravel 9 I am trying to add a prefix and group to a route and its not working. If I just route it like normal, it works but with the prefix and group I get page not found.
If I link just dashboard like below, it works but if I add /admin/dashboard it doesn't
Route::get('dashboard',[DashboardController::class,'getDashboard']);
use App\Http\Controllers\Admin\DashboardController;
Route::prefix('admin')->group(function () {
Route::get('dashboard',[DashboardController::class,'getDashboard']);
});
Can you clean up the post? What exactly happens with the nested group version? Any chance you have a route above it that matches? Like /admin/{user}
Your route URI will be /admin/dashboard after adding the group and prefix; can you confirm with:
php artisan route:list --path=admin
@tykus
GET|HEAD admin/dashboard ................................................................. Admin\DashboardController@getDashboard
Here is my complete routes. In the nested group version, I get page not found when I goto domain/admin/dashboard
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\DashboardController;
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::prefix('admin')->group(function () {
Route::get('dashboard',[DashboardController::class,'getDashboard']);
});
@artisticre what is the output of php artisan route:list
Are your routes cached??? php artisan route:clear
@artisticre any chance you have a folder named /public/admin?
Did you try clearing cache? php artisan route:clear
@Sinnbeck I had the folder called admin. Thanks
Please sign in or create an account to participate in this conversation.