john23
john23

Reputation: 279

Laravel Routes not Found

I am working with Xampp as the server. For some reason I can't get my routes to function correctly.

Route::get('/', function () {
    return "hello";
});

Route::get('about', function () {
    return "Hello World";
});

When I navigate to localhost/laravel/laravel/public/ I get the page that says "Hello".

When I navigate to localhost/laravel/laravel/public/about I get an error saying:

"Sorry, the page you are looking for could not be found. NotFoundHttpException in RouteCollection.php line 161:"

Image of Routes on Console

Upvotes: 2

Views: 897

Answers (1)

davejal
davejal

Reputation: 6133

change

Route::get('about', function () {
    return "Hello World";
});

to

Route::get('/about', function () {
    return "Hello World";
});

you just missed the / in front of about.

To see which routes are set up run the following form command line (post the result in your question by editing your question)

php artisan route:list

start a development server by running the following in your command line

php artisan serve

after that try browsing to

localhost:8000

and then

localhost:8000/about

Upvotes: 1

Related Questions