I am trying to rewrite to a PHP file in nginx without changing the URL, but php-fpm isn't processing the file and all I get is a 500.
If I remove the rewrite and visit the file directly, it works, so the .php file is not wrong.
server {
listen 80;
root /var/www/example.com/public_html;
server_name example.com www.example.com;
index index.html index.php;
add_header Access-Control-Allow-Origin *;
location ~ ^/InfoCenter/api/.*$ {
rewrite "/InfoCenter/api/(.*)" /InfoCenter/api/index.php last;
}
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
include fastcgi_params;
}
location ~/\.htaccess {
deny all;
}
}