Routing 101 - Remove part of the URL

As I said, if you use the new syntax in your config.php, it will/should work:

<?php

return [
    'debug' => false,
    'routes' => [
        [
            'pattern' => '(:any)',
            'action'  => function($uid) {
                $page = page($uid);
                if(!$page) $page = page('project/' . $uid);
                if(!$page) $page = site()->errorPage();
                return site()->visit($page);
            }
        ],
        [
            'pattern' => 'project/(:any)',
            'action'  => function($uid) {
                go($uid);
            }
        ]
    ]
];

2 Likes