Page 1 of 1

Pretty URL on NGINX and queries in the URL not working

Posted: Fri Feb 24, 2023 12:20 pm
by jpa
I'm sorry if I put this question in the wrong category, but I could not find another, more suitable category.

I have moved a CMSMS site from an apache server to a new server that runs NGINX. I set up the NGINX config to allow for pretty URLs as advised:

Code: Select all

location / {
        try_files $uri $uri/ /index.php?page=$request_uri;
}
But one of the pages in this CMS uses queries in the URL to filter the content. Like https://domain.com/accesspage?foo=bar

This URL is not working on the NGINX server, but if I add an & in front of foo=bar, it works. https://domain.com/accesspage?&foo=bar

It's as if the URL is rewritten as https://domain.com/index.php?page=accesspage?foo=bar, and that, of course, does not work

Has anyone else run into this problem?

Is there a way to edit the try_files or to add a separate rewrite rule, to make this URL work as intended: https://domain.com/accesspage?foo=bar

[SOLVED] Re: Pretty URL on NGINX and queries in the URL not working

Posted: Mon Feb 27, 2023 12:25 pm
by jpa
After some trying and failing, it seems as if I was on the right path all along, but forgot an important & in the string.

When I changed the try_files to the following, it works:

Code: Select all

try_files $uri $uri/ /index.php?page=$request_uri&$args;