Monday, July 01, 2024

Re: PHP PATH_INFO

On Mon, Jul 01, 2024 at 12:56:51PM -0400, F Bax wrote:
> I'm working on migrating a website from very old OpenSBD 4.5 to 7.5
>
> I got nginx & php mostly working in chroot environment.
>
> browser to mysite.ca/Boards.php works as expected; but when launched with
> PATH_INFO as in mysite.ca/Boards.php/SMS this presents 404 not found.
>
> A search online produced several pages where PHP script was accessed but
> $_SERVER['PATH_INFO'] was empty; so they are one step ahead of my
> situation; since PHP script does not get invoked for me.
>
> Here is portion of /etc/nginx/nginx.conf which I expect needs changing.
>
> location ~ \.php$ {

The $ at the end of the expressions makes this translate as "match any
URI that ends on '.php'". So if you request ".../Boards.php/SMS", the
expression doesn't match, because it ends with '/SMS'. That's why the
script doesn't get invoked.

As for how to correct this, you really should look into the
documentation of the application, ideally with some nginx configuration
examples. You can drop the '$' at the end, and then the regex will
match any request that has '.php' somewhere in its URI, but I make no
guarantees to whether this is a good idea, in your case or at all (I
have a hunch it isn't).

> try_files $uri $uri/ =404;
> fastcgi_pass unix:run/php-fpm.sock;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> include fastcgi_params;
> }
>
> Thanks for any suggestions to resolve this.

--

No comments:

Post a Comment