Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Header Status Handler


Jack_mcs

Recommended Posts

It checks number of things but the basic flow is that if the ID doesn't exist in the database, a 410 is returned. If it is but the quantity is 0, a 404 is returned.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Jack taking note of what @@Gergely says here I am coming to the HSH to see what you think about if this?

During a shop category / product reorganization I Google webmaster showed that some categories I am completely removing from shop are not producing 404 but rather 302 status code taking the visitor to the index page. The SEO negative is that these would then show duplicate title/descriptions for the deleted categories. At least this is how it looks at this point.

I have both HSH and the GitHub modification that Gergely authored installed on this shop and both appear to be working pretty well.

 

As Gergely noted this seems to only be occurring (so far from what I see in webmaster tools) when the endpoint category is removed. Such as in home>category level 1> sub category level 2>sub category level 3 >product where the product is relocated and sub category level 3 is then removed.

 

It is the deleted url path to sub category level 3 that is being redirected (302) to index.

 

Is this something to be looked into via HSH or as noted in Gergely's post this is something regarding validating categories otherwise?

 

Thanks

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

I'm not sure I understand the problem completely but your question made me realize I hadn't considered a cPath with more than one ID in it. I just ran a test here and the code is not working correctly because it only checks the first ID. To fix that, please find the following in the includes/functions/headerstatushandler.php file:

  if (isset($cID)) {
	  $db_query = tep_db_query("select 1 from " . TABLE_CATEGORIES_DESCRIPTION . "  where categories_id = '" . (int)$cID . "' and language_id = " . (int)$languages_id);

and replace it with

  if (isset($cID)) {
	  $id = explode('_', $cID);
	  $db_query = tep_db_query("select 1 from " . TABLE_CATEGORIES_DESCRIPTION . "  where categories_id = '" . (int)$id[count($id) - 1] . "' and language_id = " . (int)$languages_id);

Please test it and let me know if it still doesn't work correctly.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@@altoid

 

confirmed. I look after this ASAP. The problem noted in github codes (application_top.php)

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

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

try to change in application_top.php

 

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

 

to:

	  header("HTTP/1.0 301 Moved Permanently"); //301 Status
	  //header("HTTP/1.0 404 Not Found"); //302 Status

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

I'm not sure I understand the problem completely but your question made me realize I hadn't considered a cPath with more than one ID in it. I just ran a test here and the code is not working correctly because it only checks the first ID. To fix that, please find the following in the includes/functions/headerstatushandler.php file:

 if (isset($cID)) {
	 $db_query = tep_db_query("select 1 from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cID . "' and language_id = " . (int)$languages_id);

and replace it with

 if (isset($cID)) {
	 $id = explode('_', $cID);
	 $db_query = tep_db_query("select 1 from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$id[count($id) - 1] . "' and language_id = " . (int)$languages_id);

Please test it and let me know if it still doesn't work correctly.

 

Jack..changing the code as above to look like this:

 

	 if (isset($cID)) {
			 $id = explode('_', $cID);
			 $db_query = tep_db_query("select 1 from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$id[count($id) - 1] . "' and language_id = " . (int)$languages_id);
	 return tep_db_num_rows($db_query);
 }

 

the url (shop)/my-catetory-name/c-90_266_273.html

 

where category 273 has been deleted redirects back to the index file

 

cpanel shows a status 302 code for the redirect.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

@@Gergely

 

try to change in application_top.php

 

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

 

 

to:

	 header("HTTP/1.0 301 Moved Permanently"); //301 Status
	 //header("HTTP/1.0 404 Not Found"); //302 Status

 

Changing the application_top.php file as above

 

the url (shop)/my-catetory-name/c-90_266_273.html

where category 273 has been deleted redirects back to the index file

cpanel shows a status 301 code for the redirect.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

Jack..changing the code as above to look like this:

 

the url (shop)/my-catetory-name/c-90_266_273.html

 

where category 273 has been deleted redirects back to the index file

 

cpanel shows a status 302 code for the redirect.

Do you have the redirect page in the settings set to something other than the index file? What happens if you turn the url rewriter off - does it redirect as expected?

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Do you have the redirect page in the settings set to something other than the index file? What happens if you turn the url rewriter off - does it redirect as expected?

 

Redirect page is 404.shtml page it seems to be working fine other than this situation.

 

With rewriter off and testing (shop url)?index.php?cPath=90_265_224 am taken back to index.php

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

If you go to (shop)/my-catetory-name/c-273.html, or whatever the missing ID is, does it redirect to the 404 page?

 

Jack, all the following urls are redirected to index.php

 

(shopname.com)/my-product-category-c-90_266_273.html

(shopname.com)/my-product-category-c-273.html

(shopname.com)/-c-273.html

 

as well I tried a never used category.../-c-9999.html and it was redirected to index.php

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

@@Jack_mcs and

 

the 301 index.php redirection found in application_top.php after my suggested modification.

 

@@altoid

change the redirect to 404 page to original 404 header

	 header("HTTP/1.0 404 Not Found");
	 tep_redirect( tep_href_link("404.shtml", tep_get_all_get_params()) );

Edited by Gergely

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

@@Gergely

@@Jack_mcs

 

@@Jack_mcs and

 

the 301 index.php redirection found in application_top.php after my suggested modification.

 

@@altoid

change the redirect to 404 page to original 404 header

	 header("HTTP/1.0 404 Not Found");
	 tep_redirect( tep_href_link("404.shtml", tep_get_all_get_params()) );

 

With these changes, I am getting a 404, the resultant url looks something like this

(myshopurl)/404.shtml?cPath=404.shtml?cPath=133_66_167_236

 

Where cat 236 does not exist. (was deleted by me) and cats 133, 66 and 167 are still valid.

 

In cpanel, the initial redirect for the invalid url is a 302 as so:

 

71.169.107.96

/index.php?cPath=133_66_167_236

1/20/14 7:12 AM

 

302

 

and then the error page is a 200 as so

 

71.169.107.96

/404.shtml?cPath=133_66_167_236

1/20/14 7:12 AM

 

200

 

 

Shouldn't the first redirect be a 301 so google will know it no longer is valid?

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

Yes you can do it. 404 wont be good because the old SEO page value not added to landing page. I'd prefered the index.php better than 404.shtml

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

@@Gergely and @@altoid I'm not sure I'm following what changes have been made. This addon works fine with a stock shop. If the code has been altered somehow then, like with any addon, it may not work as it should.

change the redirect to 404 page to original 404 header
The code for this redirect doesn't issue a 404, regardless of if you set the header or not. At least it doesn't in the shops I tested in. Maybe your change has changed how that works. This is one of the main reasons for this addon.

 

@@altoid

Jack, all the following urls are redirected to index.php

(shopname.com)/-c-273.html

Then your altered code won't work with this addon. The redirect from this addon happens in index.php and from what is said above, a redirect has been added/altered in application_top.php so I suspect that change is bypassing the check in HSH.

 

Shouldn't the first redirect be a 301 so google will know it no longer is valid?
No, google wants either a 404 or 410 returned. This is especially true if the url may be resubmmited somehow, like in a sitemap.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

 

@@altoid

Then your altered code won't work with this addon. The redirect from this addon happens in index.php and from what is said above, a redirect has been added/altered in application_top.php so I suspect that change is bypassing the check in HSH.

 

 

OK thanks. Gergely's code is addressing a different issue with categories so it's helping clean up duplicate content in goggle.

 

i'll let things sit for a while then if needed I might remove that code and see what happens with HSH then regarding categories. In the meanwhile HSH is still dealing with deleted product fine, which is a bigger issue right now for me than categories

 

thanks

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

I haven't looked at the code Gergely added to the application top but from what he posted here it is causing a redirect. So I think you could add code there to intercept that. You would need to check that the page was a category or manufacturer page and then call the HSH function to see if it is present, if it return a good result, continue with his code. Otherwise use HSH's redirection. Or something like that. Without trying it I can't say what should go there or even if it would work but I think it would.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

I tried using this contribution with the Custom Server Error Pages contribution and everything works fine with my classic version of my site but with the mobile version I am getting over 330 500 errors in google webmaster tools. How do you get this to work with iOSC mobile version?

Edited by shelby72
Link to comment
Share on other sites

I don't have that addon installed so I can't say for sure but you will probably need to edit the catalog and product_info files in the mobile directory. The changes would be the same as for the non-mobile code.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 3 months later...

Hi again

 

The redirect to file dont seem to Work in IE 11 .. It Works ok in firefox and chrome. Any solutions ?

 

Yes this is correct. is there any possible workaround to this? the ie11 behaivor is not pretty at all

-Dave

Link to comment
Share on other sites

  • 2 months later...

i read the last 3 pages and i dont know how to  fix this, when i turn on the seo 5 url i get many errorsi install this and the addon reedirect to error page, this contribuitions it´s working fine you can see in this link

 

try

http://www.apopular.com.br/apopular/product_info.php?cPath=27&products_id=44

 

and

http://www.apopular.com.br/apopular/product_info.php?cPath=27&products_id=44-error-link-message

 

 

but when i turn on seo 5

 

example in this categorie

http://www.apopular.com.br/apopular/index.php/capa-carro-caminhonete-moto-c-21

 

this work

http://www.apopular.com.br/apopular/product_info.php/capa-carro-caminhonete-moto-capa-termica-para-moto-tamanho-maxine-1085-p-117

 

many links in the same page does not work

http://www.apopular.com.br/server_error.php?id=404

 

 

thank´s jack i´m backing to oscommerce world and if you need to translate yours addons to portuguese, send me the file I can do that.

i will try to help, but i´m very "outdated"  i did only small changes. i´m not a programmer.

 

http://addons.oscommerce.com/profile/104964

 

good weekend for all

I did, helped or traslate.

http://addons.oscommerce.com/profile/104964

 

My english it´s só poor, but of you need help in portuguese, like shipping and payment that´s make a diference in brazil, come one,

Obrigado (thank´s)

 

Link to comment
Share on other sites

  • 8 months later...

Hi Jack,  I'd like to install this on a 234 bootstrap shop I am working on.   Can you think of any conflicts?  

 

I have this running fine in a regular 234 shop with no issues.

 

Thanks

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

Hi Steve. There shouldn't be any, though I haven't tried it. Is there a latest version of BS I can download and test with? The one I have is older and the link I have seems to be broken.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Go here, lower right part of screen where it says download zip.

 

https://github.com/gburton/Responsive-osCommerce

 

That's what is being called the "edge" with all the latest commits.  I tried it out a few days ago testing the installer that Gary updated.  The install went fine.

I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can.

I remember what it was like when I first started with osC. It can be overwhelming.

However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc.

There are several good pros here on osCommerce. Look around, you'll figure out who they are.

Link to comment
Share on other sites

Thanks Steve. I thought I had tried that. It worked now though. I installed and test it and it worked fine. There is a change in the version I have here that should be applied though (for any version of oscommerce). In includes/functions/headerstatushandler.php, find

          $db_query = tep_db_query("select 1 from " . TABLE_CATEGORIES_DESCRIPTION . "  where categories_id = '" . (int)$cID . "' and language_id = " . (int)$languages_id);

and change it to

          $id = explode('_', $cID);
          $db_query = tep_db_query("select 1 from " . TABLE_CATEGORIES_DESCRIPTION . "  where categories_id = '" . (int)$id[count($id) - 1] . "' and language_id = " . (int)$languages_id);

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...