Just as an experiment, I was trying to remove my index.php
from the webroot in nginx and directly point to app.php
, as the only thing the index file does is this:
<?php
chdir(dirname(__DIR__));
include 'app.php';
My nginx setup is pretty easy:
server {
listen 80;
server_name localhost;
root /vagrant/public;
location / {
try_files $uri /index.php?$query_string;
}
# some includes here
}
And simply pointing out of the web root does not work:
server {
listen 80;
server_name localhost;
root /vagrant/public;
location / {
try_files $uri /../app.php?$query_string;
}
# some includes here
}
It is for me a bit hard to search for this case, as there are many problems popping up based on the used key words, but all related to another problem.
There is no real need for this, but with nginx such a powerful tool I can't imagine this is not possible. So, it it?
You probably only need to set the index paragraph in your nginx config. Try
index app.php;
and reload nginx.