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:
Everything is working fine on localhost.
Routes file has only:
$routes->connect(’/’, [‘controller’ => ‘Pages’, ‘action’ => ‘display’, ‘home’]);
Add other controllers routes in your Routes files and then check.
hope this works.
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!
Did you create the
.ctp files in the correct places?
Yes. All .ctp’s are in:
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
775 (if you want it a littlebit looser, go for
/pages/* is being passed to the
So assuming you go to
example.com/pages/my-page, your template should be in
example.com/pages/reviews, your template should be in
Here is my website’s source code (found at https://testing.finlaydag33k.nl), feel free to have a look, maybe you can find something useful here?
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!
Then I think something else might be wrong.
I think maybe your Apache2/Nginx config might not be right (so it’s not allowing the URL to be rewritten).