Home > database >  Laravel9 route name that's similar, not same, as other route fails to match. same content, at d
Laravel9 route name that's similar, not same, as other route fails to match. same content, at d

Time:07-17

I'm building a new Laravel9 site.

I've created some test content

For the following routes,

cat routes/web.php
    ...
    Route::prefix('test')->group(function () {
        Route::get(
            '/A',
            function () {
                return View::make('templates.pages.testA.testA');
            }
        );

        Route::get(
            '/',
            function () {
                return View::make('templates.pages.test.test');
            }
        );
    });

    Route::get(
        '/othertest/A',
        function () {
            return View::make('templates.pages.testA.testA');
        }
    );
    ...

at URL

https:/mysite.loc/test/

i see the test content.

at URL

https:/mysite.loc/othertest/A

i also see the test content.

BUT, at URL

https:/mysite.loc/test/A

, which should display the same content as @ the '/othertest/A', I get just a "404 | not found" error.

IIUC, route matches are parsed from top to bottom, so I'd expect "/test/A" to match and not get stomped on by "/test".

What do I need to change in that config for "/test/A" to match/display correctly?

CodePudding user response:

You can try clearing route cache

$ php artisan route:clear

CodePudding user response:

Did you clear the route cache after writing new routes? the most probable solution to your problem is:

php artisan cache:clear

php artisan route:cache
  • Related