| :: |
| Author |
Message |
IPB_Refugee PR0


Joined: 24 Jul 2008 Posts: 53
|
Posted: Sun Aug 17, 2008 4:44 pm Post subject: 404 instead of 200 for non existing topics |
|
|
Hello,
I tested a non existing URL of my board with web-sniffer.net, e.g.
example.com/topic-that-never-existed-t45645645656.html
And I got a page with HTTP code 200. Content of the page was, that the topic doesn't exist. I think a 404 response would be better in this case.
The same problem exists with non existing forums.
Regards
Wolfgang |
|
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 15242
|
Posted: Mon Aug 18, 2008 12:48 pm Post subject: Re: 404 instead of 200 for non existing topics |
|
|
That's phpBB's default behaviour, our SEO mod will though output proper headers (404) for forum without id that does not exist : http://phpbb3.phpbb-seo.net/404/
To fully provides with 404 headers for forums and topics that do not exists, you can add :
| Code: | | header('HTTP/1.1 404 Not Found'); |
before :
| Code: | | trigger_error('NO_FORUM'); |
in viewforum.php, two times, and before all occurrences of :
| Code: | | trigger_error('NO_TOPIC'); |
in viewtopic.php (occurs many times).
Will as well work for posts by the way
Only this occurrence :
| Code: | if (!$topic_data['topic_approved'] && !$auth->acl_get('m_approve', $forum_id))
{
trigger_error('NO_TOPIC');
} |
can be left as is, since the topic could be considered as exisitng in such case (un approved). |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
IPB_Refugee PR0


Joined: 24 Jul 2008 Posts: 53
|
Posted: Tue Aug 19, 2008 1:23 am Post subject: Re: 404 instead of 200 for non existing topics |
|
|
Thanks a lot, dcz!
I will try it soon and will give you some feedback.
If it works as expected, you should consider adding this to the code of your MOD as it seems to be really important for me.
Bye for now!
Wolfgang
BTW: phpBB's default behaviour is not always really good... But it is free software and we can improve it. |
|
|
| Back to top |
|
 |
HB phpBB SEO Team

Joined: 16 Oct 2006 Posts: 831
|
Posted: Wed Aug 20, 2008 3:11 pm Post subject: Re: 404 instead of 200 for non existing topics |
|
|
I used to return 404 and a link to a search page, but I switched to returning 301 Permanently Moved to the forum index. My thinking was that topics get deleted or mistyped in incoming links (especially from newsgroups) and it's better to return the forum index than a not found page. The other reason I decided to return 301's is because search engines appear to take them into consideration very fast. According to Google's Webmaster Tools, googlebot would ask again and again and again and again about long ago deleted topics. Returning 404 or even 410 Gone didn't seem to matter. Googlebot would continue to ask, probably assuming that the webmaster goofed and the server would change its mind.
Anyway, it's a small usability concession that I'm not entirely pleased with, but at least the bots stop nagging about dead threads. |
_________________ Dan Kehn |
|
| Back to top |
|
 |
SeO Administrateur - Site Admin

Joined: 15 Mar 2006 Posts: 4006
|
Posted: Thu Aug 21, 2008 8:31 am Post subject: Re: 404 instead of 200 for non existing topics |
|
|
True, and it's pretty easy to implement, just add :
| Code: | | $phpbb_seo->seo_redirect($phpbb_seo->seo_path['phpbb_url']); |
instead of :
| Code: | | header('HTTP/1.1 404 Not Found'); |
In the above suggestion.
And if you want to only redirect guest (thus bots) and leave the topic does not exist message (with 404 header for sanity) for registered users on dead threads and forums, you can use :
| Code: | if ($user->data['is_registered']) {
$phpbb_seo->seo_redirect($phpbb_seo->seo_path['phpbb_url']);
} else {
header('HTTP/1.1 404 Not Found');
} |
 |
_________________ phpBB SEO || SEO Forum || Forum Référencement
GYM Sitemap & RSS for phpBB3 has been released ! || GYM Sitemap & RSS for phpBB3 est disponible ! |
|
| Back to top |
|
 |
IPB_Refugee PR0


Joined: 24 Jul 2008 Posts: 53
|
Posted: Thu Aug 21, 2008 10:22 am Post subject: Re: 404 instead of 200 for non existing topics |
|
|
I prefer when non existing topics and non existing forums send a 404 header.
@dcz: Your solution works fine - thank you!
@SeO: Your code seems to miss an "!" in
| Code: | | if ($user->data['is_registered']) { |
Regards
Wolfgang |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 15242
|
|
| Back to top |
|
 |
|
|