0

I'm trying to redirect URI's ending in a single question mark to the same URI with the single question mark removed. Running nginx/1.21.6

Here's an example.

Original Request: https://domian.com/product-category/product/?

Redirect to: https://domian.com/product-category/product/

I've tried the following questions, which don't work.

  1. Can't if in an if block -> Nginx Remove Trailing Question Mark From URL
  2. Map doesn't seem to work -> nginx: [emerg] "if" directive is not allowed here

Looking at the nginx access log requests with a single question mark and nothing else on the end of the URI aren't logged with a question mark. Perhaps this is by design with nginx? Does it mean nginx doesn't record these requests, as they essentially contain no data?

Why do I need this? Google sees pages with a single question mark as valid pages because they return a 200 status code. If Google sees a page with a question mark and the same page without a question mark, the page with a question mark gets marked as a duplicate. Resulting in warnings within the Google Search console.

I would like to have these pages with a single question mark 301 redirected so these warnings are removed from Google Search Console

6
  • Unfortunately not, I updated the question to further clarify what I'm trying to achieve. Jun 14 at 15:30
  • please verify with How to Ask there is a ton of information missing
    – djdomi
    Jun 14 at 17:34
  • @djdomi a "ton" is exaggerating, I've improved the question. If you look back at all my edits, they had nothing to do with HTTP to HTTPS. Jun 16 at 19:28
  • How-to Ask - the extended. Nope, you are just fixed the formatting. But rather included the required section as I told or look similar like: how do I get better answers - What I wanted to tell you is, we are just the last edge of your search and not a solution booth that magically can read glass balls without any knowledge about the situation. ;) or with a similar its like Housten weve got a problem" -thats it ;)
    – djdomi
    Jun 17 at 8:39

0

You must log in to answer this question.

Browse other questions tagged .