Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Need to have 404 error page instead of product not found page


Guest

Recommended Posts

Hello everybody,

 

Please could someone let me know if there is a way to have a HTTP404 error page, instead of a "product not found page" (which is actually a HTTP200 page).

 

I have changed my entire website, including products database - though I have retained my original domain name. My old site, including products, was indexed by google. I therefore now have many redundant links showing up as being cached in google. They will only be removed if the pages for those links return HTTP404 errors.

 

BTW - I have installed Ultimate SEO contribution and this contribution made changes to my .htaccess file.

 

Any advice would be much appreciated.

 

Many thanks,

 

Unified

Link to comment
Share on other sites

Hello everybody,

 

Please could someone let me know if there is a way to have a HTTP404 error page, instead of a "product not found page" (which is actually a HTTP200 page).

 

I have changed my entire website, including products database - though I have retained my original domain name. My old site, including products, was indexed by google. I therefore now have many redundant links showing up as being cached in google. They will only be removed if the pages for those links return HTTP404 errors.

 

BTW - I have installed Ultimate SEO contribution and this contribution made changes to my .htaccess file.

 

Any advice would be much appreciated.

 

Many thanks,

 

Unified

 

 

Oh yeah,

 

Finally, someone has this issue.

 

if you have control panel, you can customize 404 error page.

 

I have the same satuation, and i want to know what kind of step i need to take to make sure seach engine grab all my new pages instead of old once, and what is best way to deal with redirect?

Link to comment
Share on other sites

Oh yeah,

 

Finally, someone has this issue.

 

if you have control panel, you can customize 404 error page.

 

I have the same satuation, and i want to know what kind of step i need to take to make sure seach engine grab all my new pages instead of old once, and what is best way to deal with redirect?

 

Hello Sean,

 

I have found a temporary solution (not a nice solution - but it works):

 

(1) Create a new file: catalog/includes/404.php:

 

<?php
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
?>

<hr>
<h1>404 Not Found</h1>
The file you requested could not be found.

 

(2) BACKUP catalog/product_info.php

 

(3) In catalog/product_info.php find:

 

$product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
 $product_check = tep_db_fetch_array($product_check_query);
?>

 

and ADD after the above:

 

<?php
 if ($product_check['total'] < 1) {
 // Attempting to access a file that we could not find.
 require('includes/404.php');
 exit;
 }
?>

 

What this does is queries whether the whether the product exists, and if it does not, it takes you to either the 404 page you created, or the standard HTTP 404.

 

To test this goto google and enter in the search box:

 

allinurl:YOURWEBSITE.COM

 

NB: Notice there is no www at the start.

 

This will show all pages in your site indexed by google (you may have to show omitted pages). Click on a link for a dead product, and see if it goes to the 404 page we created (or the standard 404 page).

 

As I mentioned at the beggining of the post, this method is not ideal - and is temporary, or at least until google removes all dead product links. Unfortunatle, I'm not sure on how to remove dead category/manufacturer links that have been indexed!

 

Hope this helps!

Link to comment
Share on other sites

Unified, what does this code do for sites like mine, that don't keep track of stock? most of my products are at stock 0 but still need to remain active on the site until i "delete" them via the admin panel (or put "offline")?

Link to comment
Share on other sites

The 404 error is a server-based http process/response.

 

By all means, create your own 404 page to handle errors when people link to a page that does not exist. Most 404 pages should direct the person to your home page or something close to it. You could even include a means of contacting the "web master" to let them report the broken/invalid link.

 

The 404 page should be placed in your site's root/home directory.

 

You must update the server's controls to point to your custom 404 page.

 

I believe most Unix servers provide this access through CPanel. Windows server users should contact their host. For more information, take a look here: http://plinko.net/404/custom.asp

 

Hope that helps!

 

Larry

Link to comment
Share on other sites

i already have that, but if i have a product shut "off", it still serves a 200/ok response (this is an oscommerce, not a server problem)

 

i've insterted a 404 response in the beginning of the "not found" code, but this only serves a 404 if the item has been deleted. if i turned it to inactive, it still shows a 200/ok

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...