CakePHP 4 and separate webroot

I separated webroot and put it in the web server document serving directory tree. The rest of CakePHP is outside of the public web tree. I modified index.php paths and changed paths in config paths.php also. And it works! :slight_smile: Is this the correct way to do this and are there any considerations?

(One reason is on some hosts I cannot change vhost pointing to webroot).

I’m learning cake 4.

Hello!

I’ve been doing it this way since cake 0.x :slight_smile: I use CPanel servers with the webroot being public_html

1 Like

Hi,

I am at the same points moving to online server (cakephp 4):
Could you please give me more info on how you did…
so as far as I understood, webroot content goes to public_html and index.php of the webroot should be modified and all app folders go above public_html, is this correct?
But what and how to modify in the webroot index.php and paths of the config?

Thanks for possible help.
Kind regards

Hello!

I’m sorry for answering so late. Yes, you must move the webroot / index.php file to public_html and then edit it. You only need to change the paths in index.php

Hi,

Thanks for reply.
Just the index.php?
What about all other webroot files and folders?

Thanks
Kind regards

You can move the entire content of webroot to public_html
then adjust, if necessary, lines 19, 31 and 37 in case of cake4 index.php: https://github.com/cakephp/app/blob/master/webroot/index.php

1 Like

Hi,

That’s precise :), indeed I move to cake 4.
Thanks for the accurate info

Regards