Forum Moderators: phranque

Message Too Old, No Replies

Soft 404 errors on expired pages

         

csdude55

7:34 am on Apr 13, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have a site that features classified ads. After a predetermined period, those ads expire. If you view the page after they expire, PHP redirects you back to the main page:


if (
!$expiration ||
$expiration < $today
) { header("Location:$home/?q=notfound"); exit; }


Then, of course, $home does something like this (just typed for this post):

if ($_GET['q'] == 'notfound') echo "Error message";


Beginning on March 15, though, Google Webmaster Tools started picking up these expired pages as "soft 404 errors", and it shows literally thousands of these errors.

What's the best way to fix this for Google without being penalized by Google, and be seamless to my users? My initial thought was to do this, but I'm not sure if it's the best way:


if (
!$expiration ||
$expiration < $today
) {
header(“HTTP/1.1 301 Moved Permanently”);
header("Location:$home/?q=notfound");
exit;
}

not2easy

2:32 pm on Apr 13, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



That won't change the soft 404s unfortunately because it will continue to show unrelated contents for the URL requested. Where you have:
header(“HTTP/1.1 301 Moved Permanently”);
header("Location:$home/?q=notfound");
exit;

you could try using:
header("HTTP/1.0 404 Not Found");
require("your 404 page");
exit;

replacing the "your 404 page" with the actual page name. Maybe you could set up your 404 page to capture and echo the query with an Expired notice and a link back to related pages.

(Note: my 'code' is not for copy paste - I don't know beans about php, excuse any guessing errors, please)

lucy24

7:34 pm on Apr 13, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Seems like 410 would be even better. You can show the same physical page, but the numerical response may help.

csdude55

9:09 pm on Apr 13, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Lucy, do you mean that I could still redirect like my original if I use "410 Gone", or that I should still import $home using require() the way that not2easy suggested?

lucy24

9:24 pm on Apr 13, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I mean that in not2easy's suggestion, the 404 header could be replaced with the 410 header ("410 Gone", I suppose, unless php calls it by some other name). Everything else can remain as she said-- including sending out your (physical) 404 page if you don't feel like creating a separate 410 page.

If you get a significant number of human requests for expired content, then a custom 410 page might be appropriate anyway-- "I used to have it but it's gone" sounds friendlier than "I don't know what you're talking about"-- but otherwise there's no need.

tangor

2:52 am on Apr 14, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Classified ads (the usual definition) generally have a fixed life unless open ended. When they die they should actually die a 410.

lucy24

4:05 am on Apr 14, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Also: I'm not sure "Require" is warranted here. I mean, you'd want to send out the 404/410 response even if your 404 page has unaccountably gone walkabout.