Googlebot 404 errors due to page numbers

Found this topic after encountering the same issue.

I fail to see how this is google’s problem, you can’t expect every page to be reindexed every hours.

Are you seriously saying that discourse can’t check that if a link includes ?page=2 which would translate to /21, but if the topic shrunk to 19 posts, it can’t handle that and redirect to the last post /19 in this case?

In fact, discourse already has everything ready to do it right, w/o needing to put the blame on external forces. Currently, If the topic has 19 posts and I type /99, it automatically redirects to /19 - so it knows how to handle shrinking topics just fine. So if you let ?page=2 to always redirect to /21, w/o checking whether there are 21+ posts or not, discourse will do the right thing after 2 redirects:

  1. …?page=2 => Redirect …/21
  2. …/21 => ../19

of course, I’m assuming the server is configured to handle multiple redirects.

Does this make sense?

p.s. I think the proposed solution reduces the edge case to general case and actually simplifies things, since you no longer need to check whether ?page=2 “exists” and let redirects do the right thing.