Monday, July 01, 2024

Re: PHP PATH_INFO

> Am 01.07.2024 um 18:56 schrieb F Bax <fbax.ca@gmail.com>:
>
> 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.

The above seems irrelevant to you issue.


> 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.

Huh? Are you talking about `$_SERVER['PATH_INFO']` in PHP?


> 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$ {

If your URL ends in ….php/SMS then this regex/pattern will not match. Thus the rest of the block is irrelevant.

Either find a regex/pattern that will match your URLs or use a different method to supply parameters to your script. (URL parameters come to mind for example.)

Note: This has nothing to do with OpenBSD or even PHP. This is just an nginx configuration problem. So you may be better off asking somewhere where nginx experts hang around. I don't use nginx so I don't have a ready solution for you. But that said, a quick search turned up this:

FWIW: fastcgi_split_path_info seems like it could solve your problem:
https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_split_path_info


> 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.


HTH
Mike

No comments:

Post a Comment