Answer the question
In order to leave comments, you need to log in
Why does Nginx give the PHP script to download instead of executing when adding a slash to the path?
There is a directory on the site, let's say with the name path, and if you access the address example.ru/path - everything starts up perfectly index.php, which is located in this directory, and if you access it with a slash at the end - example.ru/path / , then index.php is downloaded.
Site config
server
{
listen 80;
root /var/www/example.ru;
index index.html;
server_name example.ru;
location ~ \.php$
{
include common/php-fpm;
}
}
# Настройки порта или сокета PHP-FPM производятся в файле "/etc/php5/fpm/pool.d/www.conf"
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
# Порядок важен - строчка "include fastcgi_params" должна быть первой
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
# Вместо переменной "$document_root" можно указать адрес к корневому каталогу сервера и это желательно (см. http://wiki.nginx.org/Pitfalls)
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
# См. http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
# Additional variables
fastcgi_param SERVER_ADMIN [email protected];
fastcgi_param SERVER_SIGNATURE nginx/$nginx_version;
fastcgi_index index.php;
Answer the question
In order to leave comments, you need to log in
How about adding:
location /{
try_files $uri $uri/index.php /index.php;
}
Like you need it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question