C
C
Carry2017-09-21 15:57:29
Nginx
Carry, 2017-09-21 15:57:29

An error in the nginx config?

The problem is that test.com doesn't find the app.php file and does try_files showing me error.php;
But when I explicitly write test.com/app.php it works!
Can't understand.....
Paths: var/www/test.com /web/ ->
error.php
app.php and etc....

Site config
server {
 listen 80;
 listen [::]:80;
 charset utf-8;
 server_name test.com www.test.com;
 root /var/www/test.com/web;
 index index.php app.php;

location ~ /\. { 
 deny all;
 log_not_found off;
 access_log off;
}
location = /robots.txt {
 allow all;
 log_not_found off;
 access_log off;
}
location / {
    try_files $uri /error.php;
    index app.php;
    }
location ~ \.php$ {
    try_files $uri  /error.php;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_index app.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    include fastcgi_params;
  }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RidgeA, 2017-09-21
@RidgeA

I think you need something like

location / {
    try_files $uri /app.php?$request_uri /error.php;
    }

A
Antony Ryabov, 2017-09-21
@tonymadbrain

This is how it should work:
try_files $uri $uri/ /error.php;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question