2

The ? is not part of a query but used as if it were an actual question. Here's an example:

/how-did-penicillin-change-the-world?.html

What's the best way to redirect that URL to something like /news.html?

  • Does it work with the ? within the URL? – Steve Nov 23 '17 at 3:25
  • No, but I want to redirect to the URL that doesn't have the ? in it. – Scott S. Nov 23 '17 at 4:14
  • @ScottS. Question marks are reserved characters in URLs and therefore are required to be encoded. Your comment above is also very unclear, and your question doesn't state where to redirect to... – dan Nov 23 '17 at 5:12
  • @Dan I want to redirect it to /news.html as a catch all. – Scott S. Nov 23 '17 at 11:09
  • "The ? is not part of a query" - Well, actually it is. An unencoded ? in the URL delimits the start of the query string (whether that is the intention or not). Once you realise that then the method you use is the same for matching any other URL with a query string. – MrWhite Nov 24 '17 at 15:15