News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Deleted threads to throw a 404 header

Started by destalk, August 01, 2006, 01:49:56 PM

Previous topic - Next topic

destalk

It would be nice if threads that no longer exist (even if they have been moved to a 'deleted' board) would throw a 404 error to spiders and also for users (although it would be nice to customise the 404 page for 'real' visitors). Otherwise the pages still get listed in search engines and simply waste visitors time.

It just seems the right thing to do. ;)


ryanbsoftware

so you want the following error given if you try to access a board or topic non-existant to non-viewable to you to be customizable?

QuoteAn Error Has Occurred!
The topic or board you are looking for appears to be either missing or off limits to you. 

I believe you can customize the errors in the language files.

Thantos

The problem is that SMF doesn't really have a way to know if the topic in question was deleted, hasn't been created yet, or simply off limits.  Ok the off limits it could figure out but that'd take more time.

destalk

#3
Quote from: RCB I.T. Solutions on August 04, 2006, 09:19:37 PM
so you want the following error given if you try to access a board or topic non-existant to non-viewable to you to be customizable?

QuoteAn Error Has Occurred!
The topic or board you are looking for appears to be either missing or off limits to you. 


Hi

Thanks, But not really what I was after. I want the http header information to return a 404 'Not Found' message if the page is no longer there. Currently a deleted page throws a 200 (OK) message, which tells search engines that the page is still present and to continue to list the url as active and relevant.

destalk

#4
Quote from: Thantos on August 04, 2006, 09:23:12 PM
The problem is that SMF doesn't really have a way to know if the topic in question was deleted, hasn't been created yet, or simply off limits.  Ok the off limits it could figure out but that'd take more time.

Hi Thantos

How about a checkbox option for the admin when deleting the page, as to what http error code to send to user agents? Would that make it easier to implement? For example, I could imagine the options could be 404 (page not found), 403 (forbidden), or to leave it as it currently is. Perhaps there could also be an option to customise these error pages (or to divert to an already existing 404.html).

Any use?

ryanbsoftware

Quote from: destalk on August 04, 2006, 10:21:20 PM
Quote from: RCB I.T. Solutions on August 04, 2006, 09:19:37 PM
so you want the following error given if you try to access a board or topic non-existant to non-viewable to you to be customizable?

QuoteAn Error Has Occurred!
The topic or board you are looking for appears to be either missing or off limits to you. 


Hi

Thanks, But not really what I was after. I want the http header information to return a 404 'Not Found' message if the page is no longer there. Currently a deleted page throws a 200 (OK) message, which tells search engines that the page is still present and to continue to list the url as active and relevant.

oh i see, well i am no php scriper so i don't know for sure, but could SMF be written to thow a 404 header when displaying that message?

destalk

I'm probably even less of a PHP scripter. I can barely even use HTML. ;)

However, I have used PHP content management and directory systems that have this kind facility, so I'm making an educated guess that it can be done. Whether it is difficult or not, someone else will have to say.

Thantos

Note:  I haven't tested this out at all so it may not work.  Nor do I know if it'll have any type of negative impact.

The following *should* send a 404 header whenever the user can't see the topic, because its been delete, moved to a board they can't see, or just hasn't been created yet.

Find
Code (Load.php) Select

if ($user_info['is_guest'])
{
loadLanguage('Errors');
is_not_guest($txt['topic_gone']);
}
else
fatal_lang_error('topic_gone', false);

Replace with

header("HTTP/1.0 404 Not Found");
if ($user_info['is_guest'])
{
loadLanguage('Errors');
is_not_guest($txt['topic_gone']);
}
else
fatal_lang_error('topic_gone', false);

destalk

Thanks Thantos

I'll try it on a test board and see how it goes.

BTW, if anyone else wants to test what header message their pages are throwing, this is a useful header checker; http://www.seoconsultants.com/tools/headers.asp

Advertisement: