404 redirect "The data could not be found" page

paul2307

No avatar

2009-11-02 22:50

how to redirect the "The data could not be found" page to the homepage with "HTTP 1.1 404 Not Found" server response code?

what php file do i have to edit?

version 3.4

» Quick.Cart v3.x

O

3dfx

No avatar

2009-12-08 12:44

I need help on this topic too. Without 404 status code the search engines seem to cache pages which are no longer available...

beholder

Avatar: beholder

2009-12-08 21:21

There needs to be done a change on PHP level. Try this,

in actions_client/p.php directly under line:
$content .= $oTpl->tbHtml( 'messages.tpl', 'ERROR' );

add:
header( 'Location: http://www.yoursite.com/notfound.html' );
exit;

When you change yourserver.com for your own website name and there is no content at notfound.html, the automatic 404 server message should be triggered.

this is an ugly hack, btw. I will think of better solution later since I realized this is a simple thing that Quick Cart is missing.

beholder

Avatar: beholder

2009-12-08 22:39

allright guys, here is a much better hack. I realized that only the QC error page needs to be customized. Here is how to do it.

Edit files actions_client/p.php and actions_client/products.php and in both files after line:
$content .= $oTpl->tbHtml( 'messages.tpl', 'ERROR' );
add:
$sTitle = "Error 404 Not Found - ";

This will trigger a status update when found by search spiders. The "404 Not Found" does this when found in head section of the webpage. Here is more for an avid reader to digest on:
http://www.xmlplease.com/error404

3dfx

No avatar

2009-12-09 14:43

Well, this is something but it still doesn't send real 404 status code, which is a problem :)

3dfx

No avatar

2009-12-09 15:08

OK - here is the correct string:

header("HTTP/1.0 404 Not Found");

Works like a charm :) Thank you very much!

beholder

Avatar: beholder

2009-12-11 00:59

dude, Mr. 3dfx, you seem to tap onto something here.
Please look here:
http://www.jmarshall.com/easy/http/


I thought the "404 not found" only needs to be anywhere in the head section of the webpage but it's probably not true. I will think about this more an will try to present a comprehensive solution with a nice not found page also giving the proper http response, and I mean the Initial Response Line (Status Line) - look at the link above to see what it is.

beholder

Avatar: beholder

2009-12-11 02:16

After some considerable research I prepared another modification, this time it may be really working as supposed to. Should be "best of both worlds - user friendly and returning 404 in the initial response line. Tried in 3 different browsers.
3dfx, could you please check how this works with the search spiders?

Edit files actions_client/p.php and actions_client/products.php and in both files after line:
$content .= $oTpl->tbHtml( 'messages.tpl', 'ERROR' );
add:
header("HTTP/1.0 404 Not Found\r\n");
$sTitle = "Error 404 Not Found - ";

3dfx

No avatar

2009-12-12 15:46

Yes - it works. There are a couple of free sites which let you easily check what status code returns your web page. For example this one:
http://www.webrankinfo.com/english/tools/server-header.php
And after adding 404 in the header the search spiders know that this page is missing. There is one more interesting thing - the only important thing is the actual number of the code, so "404 Not found" is just as good as "404 This page does not exist".
I am sure that this hack will be in help for the rest of the Quick.Cart users. Thank you for your help!

beholder

Avatar: beholder

2009-12-12 16:07

thanks for the info, submitting this fix to the QC devs.

paul2307

No avatar

2009-12-12 18:40

problem also solved for me, thank you!

Back to top
about us | contact