
What you need
- Computer and internet: a laptop or desktop and a stable connection
- System: Windows 10 or 11, macOS or Linux
- Tools: PHP 8.3 or newer, Composer, Git and a code editor (the Laravel installation guide lists the official one-command installer)
- Before this: Your first Laravel route
Download only from each tool's official site and check the address before installing.
The situation
A teammate added an "About" page to a Laravel app and says it works on their laptop. On yours, http://127.0.0.1:8000/about-us shows 404 Not Found. Your job: find out why using evidence, fix it, and explain the cause in one sentence.
This exercise practises the skills from Your first Laravel route. Try it on your own first; the hints and the solution are at the end.

Resist the urge to change things at random. A 404 is a precise message: no route matched. Your job is to find out why not.
Set up
Work in a fresh practice project, not in laravel-app: your laravel-app already has an About route from the lesson, and two routes with the same name would hide the bug you are hunting. From your workspace:
cd ~/ewoi-learning composer create-project laravel/laravel route-exercise cd route-exercise
| Command | What it does |
|---|---|
cd ~/ewoi-learning |
Moves you into your learning workspace |
composer create-project laravel/laravel route-exercise |
Creates a new Laravel 13 app in a folder called route-exercise (a minute or two) |
cd route-exercise |
Moves you into it. Every command below runs from here |
Replace everything in routes/web.php with exactly this code (it contains the bug on purpose):
<?php
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('home');
});
Route::post('/about', function () {
return view('about');
})->name('about');
Create resources/views/home.blade.php:
<h1>Welcome</h1> <a href="/about-us">About us</a>
And create resources/views/about.blade.php:
<h1>About us</h1> <p>We build things.</p>
Start the server with php artisan serve, open http://127.0.0.1:8000, and click the link. You should see a 404 page. That is the bug, working as planned.
Before you change anything, save the broken version so you can compare later:
git init git add . git commit -m "Start the broken route exercise"
Your task
- Find every reason the page does not load. (There is more than one.)
- Fix them so the link opens the About page.
- Make the link survive a future change of address.
- Write one sentence for each cause, as you would in a pull request.
How to check your work
php artisan route:list --path=aboutshows a line starting withGET|HEADforaboutand the nameabout.- Clicking the link on the home page shows "About us".
- Changing the route's address (for example to
/who-we-are) does not break the link.
Want an automatic check? Our public repo has a small test for this exercise: https://github.com/ewoibuilds/practical-software-development/tree/main/step-02-fix-the-broken-route. Copy starter/tests/Feature/AboutPageTest.php into your project's tests/Feature/ folder and run php artisan test. On the broken version it reports failures; when you have fixed everything, every test passes.
Hints (open one at a time)
php artisan route:list --path=about. On the broken version it shows POST about. Compare the method and the address with what your browser requests. The Network tab in your browser's developer tools shows the method too.Ask your AI assistant
I am doing a Laravel exercise: a link returns 404. Here is my route and my link: [paste both]. Do not tell me the answer. Ask me two questions that help me find the cause myself.
Solution
Try for at least 20 minutes before reading on.
There are two causes:
| Cause | Evidence |
|---|---|
The route accepts only POST, but clicking a link sends GET |
route:list shows POST about |
The link points to /about-us, the route listens on /about |
The browser requests /about-us; no route has that path |
The fix:
Route::get('/about', function () {
return view('about');
})->name('about');
And the link in resources/views/home.blade.php, built from the route's name so it always follows the route:
<a href="{{ route('about') }}">About us</a>
Save the fix as its own commit, so the history shows the broken version and the repair:
git add . git commit -m "Fix the About route method and link"
The pull request sentences: "The About route only accepted POST, but links send GET, so it never matched." and "The link was hard-coded to /about-us while the route was /about; it now uses route('about') so it follows the route."

Notice how the evidence (route:list and the Network tab) gave you both causes without guessing. That habit is worth more than this exercise.
Go further
- Change the route's address to
/who-we-areand confirm the link still works. - Add a second page with a route parameter,
/team/{name}, that greets the person by name. What happens with/team/and no name?
Check your understanding

Every lesson stays free. Tap the thumbs up so we know what works, or say thanks with a soda or a coffee: it pays for hosting and new lessons.


