erik
erik

Reputation: 1

Laravel 5.3 NotFoundHttpException

I'm trying to setup a Laravel 5.3 project. I have create the project and starting the 'localhost//public' shows the welcome screen just fine.

When adding a test entry in the web.php file like

Route::get('about', function () {
    return view('welcome');
});

An then trying to access this as 'localhost//public/about' I get this NotFoundHttpException in RouteCollection.php line 161: error. I'm really puzzled as to whats wrong.

In the 5.2 version, with the routes.php, it worked perfectly fine.

Regs.,

Erik

Upvotes: 0

Views: 678

Answers (3)

umun
umun

Reputation: 11

You can try adding a 'public' prefix for the web routes in app\Providers\RouteServiceProvider.php like so:

    protected function mapWebRoutes()
    {
        Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
            'prefix' => 'public',
        ], function ($router) {
             require base_path('routes/web.php');
        });
    }

Upvotes: 0

erik
erik

Reputation: 1

Well its a strange story when using artisan route:list the about neatly pops up. However when accessing through Chrome i wasn't able to load it. I have dropped the whole www directory and started afresh. Now it works. Must have been something lingering around.

Thx.,

Erik

Upvotes: 0

Iftikhar uddin
Iftikhar uddin

Reputation: 3182

NotFoundHttpException means Laravel can't found the requested route. Hence, you are trying to access something which doesn't exist that's why it is throwing NotFoundHttpException.

Try to access your route like

localhost/public/about

Upvotes: 0

Related Questions