Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

artisticre's avatar

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']);

});

0 likes
7 replies
Sinnbeck's avatar

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}

1 like
tykus's avatar

Your route URI will be /admin/dashboard after adding the group and prefix; can you confirm with:

php artisan route:list --path=admin
artisticre's avatar

@tykus

 GET|HEAD       admin/dashboard ................................................................. Admin\DashboardController@getDashboard
artisticre's avatar

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']);

});
tykus's avatar

@artisticre what is the output of php artisan route:list

Are your routes cached??? php artisan route:clear

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@artisticre any chance you have a folder named /public/admin?

Did you try clearing cache? php artisan route:clear

Please or to participate in this conversation.