Using: CodeIgniter v4.4.4

On Linux: Apache2 & PHP 8.1.2

This tutorial in codeigniter 4 user_guide

I followed the tutorial exactly.

I can see code igniter ‘developer mode’ when I navigate to localhost

but when I do localhost/about I get a 404.

// here are some file details;

in /app/config/app I changed the base_url:
public string $baseURL = ‘http://localhost/public/’; # without public same result

// Here is my ‘routes.php’ file exactly as in the tutorial


use CodeIgniterRouterRouteCollection;
use AppControllersPages;

 * @var RouteCollection $routes
 * ref:
$routes->get('/', 'Home::index');
$routes->get('pages', [Pages::class, 'index']);
$routes->get('(:segment)', [Pages::class, 'view']);

// The About pages just like they wanted in the tutorial

├── pages
│   └── about.php
├── templates
│   ├── footer.php
│   └── header.php
└── welcome_message.php

// And lastly my Pages.php controller file in /app/Controllers/Pages.php


namespace AppControllers;

use CodeIgniterExceptionsPageNotFoundException;

class Pages extends BaseController
    public function index(): string
        return view('welcome_message');

    public function view($page = 'home')
        if (! is_file(APPPATH . 'Views/pages/' . $page . '.php')) {
            // Whoops, we don't have a page for that!
            throw new PageNotFoundException($page);

        $data['title'] = ucfirst($page); // Capitalize the first letter

        return view('templates/header', $data)
            . view('pages/' . $page)
            . view('templates/footer');

What am I missing here? I had it working in version 3.
I had it working in version 4 on another project.
I just can’t figure out why? Its literally copy paste from tutorial.