Imagine a pagination script with 20 total pages:articles.php?page=18What should I do when some third party web site links to a non-existent page?articles.php?page=21      (page 21 is out of bounds)articles.php?page=-10     (as is this)articles.php?page=blabla  (or this)problem is... (I have 20 total pages)some 3rd party site links articles.php?page=21 that doesn't exist (last page is the 20th)and I send 404/301 as a responseGoogle crawls that linksome time after, the total number of articles increases and will make the 21st page appearthe 404/301 will be removed in favor of the status 200Is that correct? Is 404 or 301 better? Do I need some more expedients?(with a 301 redirect I mean redirecting to the closest valid page)more answers are welcome!!
What Google will do while switching from 301/404 to 200?
seo;google;301 redirect;404;canonical url
Google will not penalise you when another site links to a page on your site returning a 404.  Neither will you get any Google juice for that incoming link.When you at some later point create that page, and the response code switches from 404 to 200, Google will notice that you have an incoming link to a working page, and if somebody out there links to that page, the appropriate Google juice will start flowing your way from then on.If you redirect (301) Google will pick up the new URL and any Google juice passed by the bogus link will actually be credited you before the page linked to exists.  From a SEO perspective, that is a bonus - but IMHO also slightly deceptive. (But it won't get you blaclisted by Google.)When you create that page, and the response code switches from 301 to 200, Google will just think the content on the page has changed, and re-evaluate its relevance based upon the new content.