Just moved a project from localhost to hostinger server. CakePHP connects to database, shows home page(that requires database connection). When trying to go to any “Pages” page, everything is fine, it loads up. When trying to use any other controller(user login, user register, reservation add, review add, menu index), none of them work.
This is the errror it makes:
Tried adding this way:
$routes->connect(’/reservation/:action/*’, [], [‘controller’ => ‘Reservation’]);
$routes->connect(’/reservation/’, [], [‘controller’ => ‘Reservation’, ‘action’=>‘index’]);
neither of these work, these links do not change - it seems that i didn’t even make any changes!
Yes. All .ctp’s are in:
src/Template/…/.ctp
for instance:
src/Template/User/login.ctp
I believe that pages route overwrites all the other routes, that’s why it cannot access any other routes. I have no idea how to change the pages route from / to /pages/*, since this is what i already have in routes is:
When things work fine on development but not production, it’s most commonly either because dev is Windows and production is Linux and you’ve used file names with the wrong case (Windows is not case sensitive, so it doesn’t matter, but on Linux it does), or else file/folder permissions are wrong somewhere.
Could you help me out with permissions? I have no idea on what files should have what permissions, and there is no info about it…
Most files were generated by baking, mostly just .ctp files were made by hand.
Simply speaking, all files and directories should have the owner and group as the user and group that runs the php interpreter (most commonly www-data should do for both) and be chmodded to 755 or 775 (if you want it a littlebit looser, go for 775).
also, your route for /pages/* is being passed to the PagesController.
So assuming you go to example.com/pages/my-page, your template should be in src/Template/Pages/my_page.ctp.
Or assuming example.com/pages/reviews, your template should be in src/Template/Pages/reviews.ctp.
Thank you!
Yes, i understand that all of them should be there.
Problem is, I put in routes /pages/, but it acts as if it was /.
For example, I want:
…/pages/contacts, I have this-> …/contacts.
This is the reason I cannot access any other controllers - their links are overwritten by Pages controller… And i don’t know why it does not read the routes file… And it did not read it even in localhost!