Check it out... question for anyone who's really familiar with how HTTP and Apache work. If I want to move a page on my site, say, from somefile.php3 to somefile.php, I can rename the file, but I want to leave some indication that the file moved, for a while at least, so that search engines can update their records (except Inktomi which continues searching to this day for pages I haven't had on my site for years).
I can do one of two things. I can leave a dummy page in the old place (since the page is PHP I can write code there...) which I can have send a 301 return code to indicate that the page has been "moved permanently", and give the page's new location. Alternately, I can just let the person get a 404, and then have my 404 page (it's PHP again
try to find the current version of the page. For instance, if someone looks for somefile.htm, somefile.html, somefile.php3, somefile.phtml, etc. I can have it look to see if there's a somefile.php and automatically redirect them to that from the 404 page.
My questions are: is it wrong to send a Location: header from a 404, and does that really "mean the same thing" as a 301? Will spiders treat it similarly? Finally, is there any way to suppress the 404 code if I can figure out through code that the page actually exists, sending a 301 code and a Location: header instead? What would I have to do with Apache to make this happen?
I just realized I forgot to explain a little of my reasoning. I'd much rather have the logic put in my 404 page because there I can have it all in one place rather than having dummy files cluttering up my web space for every page I've ever had on my site that might exist with another name. The thing is, I don't want to be returning 404 codes if the page does exist but has just moved, because that's what 301 is for.
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):