I want Nginx to load only index.php on every URL coming in
example.com/urlb?id=1 example.com/urlc?id=2 example.com/urld?id=3 my /etc/nginx/sites-available/default looks as the following -
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.php index.html index.htm;
server_name html;
location ~ \$ {
try_files /index.php$is_args$args;
include snippets/fastcgi-php.conf;
fastcgi_pass unix://var/run/php/php7.3-fpm.sock;
}
}
I want for all the URL above or any URL in the feature to always load index.php
}`
– Mat Cn Jun 22 '20 at 05:26nginx -tsays? – Ivan Shatsky Jun 22 '20 at 05:27fastcgi_passdirective, tryfastcgi_pass unix:/var/run/php/php7.3-fpm.sock;– Ivan Shatsky Jun 22 '20 at 05:28/etc/nginx/snippets/fastcgi-php.conffile? – Ivan Shatsky Jun 22 '20 at 05:38Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
Bypass the fact that try_files resets $fastcgi_path_info
see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info; fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php; include fastcgi.conf; `
– Mat Cn Jun 22 '20 at 05:39index.phpand error code, which can be implemented withtry_fileslike my answer shows. – Tero Kilkanen Jun 22 '20 at 06:41