handling a GET error properly

Posted by Andrew Heath on Programmers See other posts from Programmers or by Andrew Heath
Published on 2012-10-23T01:09:08Z Indexed on 2012/10/23 5:25 UTC
Read the original article Hit count: 335

Filed under:

I have a website that takes two primary get strings:

?type=GAME&id=SomeGameID
?type=SCENARIO&id=SomeScenarioID

for reasons unknown, I have recently begun receiving requests for erroneous get strings from both Yandex and Baidu. They are always in the form of:

?type=GAME&id=SomeScenarioID

None of my users are triggering these errors, so I am (sort of) confident that this is not due to an HTML template error somewhere on my part. There is also no HTTP_REFER showing up in the $_SERVER array, so I'm guessing these are direct requests from bad dbase data on their part.

I see two options for dealing with these bad requests, and would like to know which is recommended... or if there are other, better options I have not thought of:

  1. simply 404 the request, since it is incorrect
  2. redirect the request to ?type=SCENARIO&id=SomeScenarioID because the scenario IDs are always valid, the breakage is due to asking for the wrong type.

© Programmers or respective owner

Related posts about error-handling