Base route (/) under prefix

Posted 8 months ago by RinoDrummer

Hi all!

I'm having problems when I try to reach the base route of the admin panel I'm building.

Suppose that I have it on: http://localhost/admin/

When I type that URL, I get a Forbidden error page. That doesn't happen when I visit the Auth routes, the dashboard route and general one for controller/action.

I use Laravel 5.5.

This is the interesting code fragment of my web.php:

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

    Route::middleware(['auth'])->group(function () {
        Route::namespace('Admin')->group(function () {
            Route::get('/', '[email protected]')->name('panel'); // Added name
            Route::get('/dashboard', '[email protected]')->name('dashboard');

            Route::get('/{controller}/{action?}', '[email protected]')->where([
                'controller' => '[a-z]+(?:-[a-z]+)*',
                'action' => '[a-z]+(?:-[a-z]+)*'

This is a snippet of Admin\PageController.php:


namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use Auth;
use \App\Data;

class PageController extends Controller
    public function dashboard() {
        if (Auth::check()) {
            $data = Data::all();

            return view('admin/dashboard')->with('data', $data);

        return redirect()->route('login');

    public function action($controller, $action = 'index') {

        if (Auth::check()) {
            return studly_case('controller') . 'Controller' . '@' . $action;

        return redirect()->route('login');

And this is the output of php artisan route:list: Laravel routes list

Thanks in advance!

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.