Before we start, I have searched and read for hours both on this discourse and various google searches about deploying Cake apps. I fully understand that Cake is designed to use mod_rewrite and that what I am trying to do SHOULD just work. I have read the bits about setting RewriteBase, nothing I have tried from that reading has accomplished anything.
In any event, I tried before I posted here, really I did. I have a fully running app, but I’m having trouble deploying it.
Running Cake version 4.1.6 PHP 7.4.9 Apache 2.4.46 WAMP server 3.2.3 64bit on Windows 10
The Cake app is in \wamp64\www\myapp
If in command I cd there and type bin\cake server the server starts up and everything works just excellently. I browse to
http://localhost:8765
and the system redirects (as it should) to
http://localhost:8765/users/login?redirect=%2Fmyapp%2F
and the entire app runs as it should. I can log in, list, edit, view, page, all that good stuff. Very nice. I have not used Cake before but I must say this is very nice stuff. This app went together in near record time.
Anyway, time for the massive fail…
I then clear the tmp folder, clear the browser’s cache (or use a different browser), and try to access the app from the WAMP server.
I go to
http://localhost/myapp/
and the server attempts a redirect to
http://localhost/users/login?redirect=%2Fmyapp%2F
which gives a 404.
If instead I try to open
`http://localhost/myapp/users/login
The login page opens up quite nicely, but the same usernames and passwords that work so well in the cake server (localhost:8765) pop up the box that says that my username or password is incorrect. I presume this because the paths don’t work.
When I deploy this to the client’s server it will have to exist at https://www.myclient.com/myapp and not at (what from extensive reading I presume to be the Cake normal) https://myapp.myclient.com That would be nice and all, but I don’t have that as an option in this case, so here I am.
I have wondered if this piece of code in webroot/index.php has something to do with it, but I honestly don’t understand what it is trying to tell me.
// For built-in server
if (PHP_SAPI === 'cli-server') {
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
$url = parse_url(urldecode($_SERVER['REQUEST_URI']));
$file = __DIR__ . $url['path'];
if (strpos($url['path'], '..') === false && strpos($url['path'], '.') !== false && is_file($file)) {
return false;
}
}
In your collective minds, what have I done wrong, where should I look, what might I try next?