Posts Learn Components new Snippets new Categories Tags About Device Beast sponsor

Nested Route Group in Laravel

Learn how to define nested route group in Laravel and simplify your code.

Created on Jul 12, 2021


In Laravel you can nest route group, what that means is that you can create a group within a group. To achieve that you can define your route like below.
Route::group(['prefix' => 'hello'], function () {
    Route::group(['prefix' => 'world'], function () {
        Route::get('/', function () {
            return 'hello world';

So now you can access the route by entering "/hello/world" and get the "hello world" string back as response.

Snippets by

PostSrc poster


Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

Load comments for Nested Route Group in Laravel


PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components

Other Code Snippets