Nginx duplicating query string on redirect

Viewed 1659

I am trying to redirect all traffic from urls that contain 'www.' to the similar url that does not contain it, but when I do so Nginx appends a duplicate query string at the end of the url.

For example, the user enters:

 www.website.com/test/?_id=12345

And they get redirected to:

website.com/test/?_id=12345?_id=12345

Here is my config:

server {
  server_name www.website.com;
  return 301 $scheme://website$request_uri permanent;
}

server {
    server_name website.com
    # actual server stuff
}

I have tried appending a '?' to the end of the redirect after the 'request_uri' portion because form what I have read that should work, but it didn't.

1 Answers
Related