I’m still a beginner who’s still following the 20min CMS tutorial. CakePHP 4.x
Site: Authentication.
Issue: Not-logged-in users should be redirected to sub.domain.tld/cakefolder/users/login but instead get redirected to sub.domain.tld/users/login.
Edit: The project was created in said cakefolder/, it’s the root folder with the webroot and everything else beside it. This is why this issue is not quite understandable to me.
I guess this is due to the lines
$authenticationService = new AuthenticationService([
‘unauthenticatedRedirect’ => ‘/users/login’,
‘queryParam’ => ‘redirect’,
]);
in Application.php
I could change the path in the array but I guess that wouldn’t be the right way, as there’s another of those somewhere else…
So how/where to correct that?
Because I’m just trying to figure things out and I think it’s well placed in a “test.domain.tld/cakefolder/”. Right next to /phpBB2/ and /phpKit/.
Also, the Quickstart Guide didn’t teach me otherwise, so I don’t know any better. I’d appreciate any recommendation for a good, spoonfeeding tutorial.
I know that I’ve run into issues running authentication in particular when the Cake app is in a subfolder. It’s most certainly solvable, and I know I’ve done it, but it was trial and error on my part, and I don’t have a good way to look at my code and tell which lines in particular are to support that capability. So if you’re just learning, my recommendation would be to do it without the subfolder in the path, as that adds an extra barrier to learning.
Maybe somebody else will have some specific advice on how to accomplish this.
maybe change redirect path to [‘controller’ => “Users”, action => “login”]
I don’t know if it should work, but you can try. Giving links with slash / prefix may lead to server root directory. You can also try to omit this first slash.
And you can use URL builder if […] doesn’t want to work.