Linking from prefix route to non prefix route

Hi all, I am using an Admin prefix route and from the admin view need to link to non admin pages.

Have tried the following:

$this->Url->build([
                'controller' => 'Users',
                'action' => 'index',
                'prefix' => NULL
                
            ]);

Also tried with empty string instead of null, but it did not work. The result if using null is that the admin route is used (result is /admin/users/index) , and if using empty string there is an exception that no route exists with prefix “”.

This behaviour is obvious when looking at the core Router.php code:

// Keep the current prefix around if none set.
if (isset($params['prefix']) && !isset($url['prefix'])) {
    $url['prefix'] = $params['prefix'];
}

Creating a NonAdmin prefix and the needed routes just to be able to escape the Admin route does not sound like a solution.

Am I doing a wrong assumption about how it should work or how to get rid of the prefix? Suggestions? Shall i file a bug report?

Using cake 4.3.6

isn’t it prefix => false?

2 Likes

Yes! I forgot to try that option, how blind I was…

Thanks!!!