I'm trying to deploy a web application for building REST services. The application is built using PHP and you BYO web server and database software. I'm using Nginx and MySQL (MariaDB). I've managed to deploy it using the following Nginx config:
server {
listen 80;
listen [::]:80;
root /var/www/fusio;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~ ^.+.php {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
}
}
When I deploy new endpoints in the application, they deploy at http://localhost/local/index.php/my_url. I would like them to deploy at http://localhost/my_url. The developer of the application, who is familiar with Apache, suggested I enable mod_rewrite, which as I understand it is effectively a redirection capability.
I want to know how I can do the same redirection in Nginx without breaking the fastcgi config I have set up. Is it possible, and if so how? The existing rewrite
s I've tried such as rewrite ^/index.php/(.*) /$1 permanent;
and rewrite ^(.*)$ /index.php
don't seem to do the trick.
Thanks in advance