Jump to content

Archived

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

acidvertigo

Need 404 header if categories doesn't exist

Recommended Posts

I have seen on previous post how to give 404 error if the product not exist. But how i can work this if categories no more exist?

 

I am on IIS server and i want to redirect to 404.htm page on this server if gategories = 0

 

Any help is more appreciated :lol:

Share this post


Link to post
Share on other sites

you just answered your own question! Are you saying you don't know how to code that?


Nothing unreal exists

Share this post


Link to post
Share on other sites

I'm having the same problem. If I key in a category that doesn't exist on my site, I get the "Home" from the beginning of the breadcrumb trail as the heading for that page and the "There are no products to list in this category" message.

 

Can anyone tell us how and where we would code it to go to the 404 page instead?

 

Thanks,

Nancy

Share this post


Link to post
Share on other sites
I'm having the same problem. If I key in a category that doesn't exist on my site, I get the "Home" from the beginning of the breadcrumb trail as the heading for that page and the "There are no products to list in this category" message.

 

Can anyone tell us how and where we would code it to go to the 404 page instead?

 

Thanks,

Nancy

modify your catalog\index.php

 

locate this code:

$category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");

 

right above it add:

	  $category_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");
  if(!tep_db_num_rows($category_query) ) {
	tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
  }

I did a simple redirect to the cookies page but you can easily replace with a 404 instead of the redirect.

 

header( "HTTP/1.1 404 Page Not Found" );

header('Location: ' . 'Some 404 error Page');

tep_exit();

and you can put your own content.

Share this post


Link to post
Share on other sites
modify your catalog\index.php

 

locate this code:

$category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");

 

right above it add:

	  $category_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");
  if(!tep_db_num_rows($category_query) ) {
	tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
  }

I did a simple redirect to the cookies page but you can easily replace with a 404 instead of the redirect.

 

header( "HTTP/1.1 404 Page Not Found" );

header('Location: ' . 'Some 404 error Page');

tep_exit();

and you can put your own content.

 

Yeah! It works many thanks! :thumbsup:

Share this post


Link to post
Share on other sites

×