/Users works fine, /users redirects to /webroot/users

I’m working with generated paginator links and it’s an issue. Everywhere else I’ve just referenced the URL’s as /Users with no issue. I’d rather it just work as /users like it’s supposed to.

Cake 3.6.14
Fedora 28
PHP 7.2.14

Cake installed with composer to /var/www/school

.htaccess in /var/www/school

<IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteRule    ^$    webroot/    [L]
     RewriteRule    (.*) webroot/$1    [L]

.htaccess in webroot

 <IfModule mod_rewrite.c>
     RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^ index.php [L]

More info:

The paginator creates a link like /users?page=2. This is redirected to /webroot/users/?page=2.

If I manually change the address bar to /users/?page=2 then it works fine.

Is this an .htaccess problem or something else? Why does the trailing slash make a difference?

Might be related to your routing configuration?

This is an old question but the same just happened to me and solved it.

I have a MoviesController and also had a folder in webroot called “movies”. Renaming the folder was the solution.

Also, be aware of browser cache because even after renaming it, the bowser still may have a cached 301 redirection.