0

I have the strangest bug. I have a site with two languages, Norwegian and English. In my code i check for craft.request.getQuery('prodid'). Locally in Apache this works fine with both language URLs, but in production on Nginx, it only works on the Norwegian version (the main language).

The URLS looks like this

For the english URL (the second) craft.request.getQuery('prodid') returns an empty string. For the Norwegian URL it returns "1".

Nginx rewrite code:

location / {
    try_files $uri $uri/ @rewrites;
  }

location /en/ {
   try_files $uri $uri/ @enrewrites;
  }

location @enrewrites {
    rewrite ^/en/(.*)$ /en/index.php?p=$1? last;
  }

location @rewrites {
rewrite ^(.*) /index.php?p=$1 last;
}
  • 1
    Can you share/double check your nginx conf file? My guess is that your rewrite rule is dropping all querystrings in the URL. – Brad Bell Dec 21 '15 at 18:52
  • You were right, I'm not a server guy myself but noticed a question mark that was out of place, removing it fixed the issue. – KnutSv Jan 4 '16 at 9:03
1

Turns out the problem was with the Nginx config as Brad suggested. There was a question mark behind the p=$1. When we removed the ? and restarted PHP it worked.

location / {
    try_files $uri $uri/ @rewrites;
  }

location /en/ {
   try_files $uri $uri/ @enrewrites;
  }

location @enrewrites {
    rewrite ^/en/(.*)$ /en/index.php?p=$1 last;
  }

location @rewrites {
rewrite ^(.*) /index.php?p=$1 last;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.