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.

Table Of Content

  1. Serving static files
  2. Serving PHP content
  3. The End
Serving static files

Static files are served directly from the webroot folder, so the Nginx configuration blocks looks like something below:

Serving PHP content

Other requests will be directed to index.php file which leads to the CakePHP's router:

The End

In this tutorial, we demonstrate how to set up a CakePHP 3 in a subdirectory using Nginx. Hope you find this technique useful.