In the most cases, we place the Laravel in the root path /.
As a result, the nginx configuration becomes
1 2 3 |
location / { try_files $uri $uri/ /index.php?$args; } |
However, if we want to move Laravel inside other directories, we must also change the location directive along with the public/index.php file.
Let’s say we want to move to the /app directory. Then the location directive would become
1 2 3 |
location ~ ^/app/. { try_files /$uri $uri/ /app/index.php$is_args$args; } |
Since nginx indicates the root path already, so we have to always refer from the root path.