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

COACHTHEM's avatar

Prefix routing not working.

I have implemented prefix routing for my admin panel on my local machine which works fine.

I am using virtual hosting on my local which is lara6.com. I have my admin panel which I access using lara6.com/admin link. For this to implement I am using prefix routing. below is my code.

Route::prefix('/admin')->group(function () {

    Route::prefix('/site')->group(function () {

        Route::get('/', 'admin\SiteController@index');
    }

    Route::prefix('/user')->group(function () {

        Route::get('/', 'admin\UserController@index');

    }

}

Now if I visit lara6.com/admin/site and lara6.com/admin/user both works fine. But when I push my changes on actual dev server which looks like this dev.myapp.com/admin with this I am not able to access the dev.myapp.com/admin/user

Any help would be appreciated. Thanks.

0 likes
7 replies
COACHTHEM's avatar

Hi @bobbybouwmann yes /admin/site works. And also /admin/site/anothersegment works. site's routes are placed on top and then I have other sections such as user section. all those after site does not work it says Sorry, the page you are looking for could not be found.

I am just using the $this->middleware('auth'); middleware in all my controller's constructor method including siteController

crnkovic's avatar

Check out the log file for errors, or enable the debug just so you can see the error.

bobbybouwmann's avatar

It looks like that route is either not found or you have an error somewhere. Do you see the route when you run php artisan route:list?

COACHTHEM's avatar

After executing php artisan route:list on the server it was showing a syntax error in one of my controller. Now I have sorted that error. And now if I execute above artisan command it list me all the Routes including other admin routes. below I have listed some.

|        | GET|HEAD                               | admin/user                                                         |                  | App\Http\Controllers\admin\UserController@index                                            | web,auth     |
|        | POST                                   | admin/user/changestatus                                            |                  | App\Http\Controllers\admin\UserController@changestatus                                     | web,auth     |
|        | POST                                   | admin/user/delete                                                  |                  | App\Http\Controllers\admin\UserController@delete                                           | web,auth     |

But still the admin URI are not working.

COACHTHEM's avatar

@bobbybouwmann I can see all my routes when I run php artisan route:list also I dont have any error. What else could be the reason for routes not working.

is it something to do with php version or nginx

bobbybouwmann's avatar

Does any of your routes work? It that is the case there is something wrong in your controller or route definition!

Please or to participate in this conversation.