When placing a CakePHP 3 project to a subdirectory, it will not work out of the box. Some specific Nginx setups are required for it to work.
For demonstration purposes, suppose we want to place a CakePHP 3 project to a subdirectory called demo.
Static files are served directly from the webroot folder, so the Nginx configuration blocks looks like something below:
location ~* /demo/(.*)\.(css|js|ico|gif|png|jpg|jpeg|ttf|woff)$ {
root /var/www/your-website.com/public/demo/webroot/;
try_files /$1.$2 =404;
}
Other requests will be directed to index.php file which leads to the CakePHP's router:
In this tutorial, we demonstrate how to set up a CakePHP 3 in a subdirectory using Nginx. Hope you find this technique useful.