Author Topic: No 404 error code on incorrect URL?  (Read 425 times)

EvanGR

  • Jr. Member
  • **
  • Posts: 426
No 404 error code on incorrect URL?
« on: March 22, 2021, 14:36:17 pm »
Hello,

I have the following issue:
When I visit a 'wrong' product URL, virtuemart takes me to the product category with a status code 200.

I don't mind being shown the product category page, this is a good strategy, but I need the 404 status code to be received properly.

VM 404 error handling setting is turned on.

[Joomla 3.9.24, VM 3.8.8]

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10118
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: No 404 error code on incorrect URL?
« Reply #1 on: March 22, 2021, 14:42:15 pm »
Quote
VM 404 error handling setting is turned on.

turn it off and u will get a 404 ..  the setting means just redirect to the category if the product is unpublished to "prevent" 404s
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

EvanGR

  • Jr. Member
  • **
  • Posts: 426
Re: No 404 error code on incorrect URL?
« Reply #2 on: March 22, 2021, 15:03:30 pm »
Thanks...

Is it possible to redirect to the category but with a 404 status code?

It's important for SEO and also for custom scripts we are building.

Could you (or anyone) point me to the core file that handles this so that maybe I could override it.

Thanks!

EDIT: I disabled VM 404 handling... and nothing has changed, I still get directed to the category page, with a wrong URL and a status code 200.

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1091
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: No 404 error code on incorrect URL?
« Reply #3 on: March 22, 2021, 15:09:49 pm »
Quote
EDIT: I disabled VM 404 handling... and nothing has changed, I still get directed to the category page, with a wrong URL and a status code 200.

Look inside your template.
Some of templates (specially JoomlArt) have custom override for virtuemart template and error code php.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

EvanGR

  • Jr. Member
  • **
  • Posts: 426
Re: No 404 error code on incorrect URL?
« Reply #4 on: March 22, 2021, 15:58:33 pm »
Look inside your template.
Some of templates (specially JoomlArt) have custom override for virtuemart template and error code php.

I switched over to vmbeez3 template, and removed my custom template from the server.... still no 404 error on wrong product URL. Just the category page and status code 200.

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1091
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: No 404 error code on incorrect URL?
« Reply #5 on: March 22, 2021, 17:37:15 pm »
hmmm :(
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3455
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: No 404 error code on incorrect URL?
« Reply #6 on: March 22, 2021, 17:55:54 pm »
Emptied cache in Your browser, using Chrome perhaps ?

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

EvanGR

  • Jr. Member
  • **
  • Posts: 426
Re: No 404 error code on incorrect URL?
« Reply #7 on: March 23, 2021, 09:11:58 am »
I also tried with Firefox.

Besides the test site, we have 2 sites, on different servers, with very different templates... one is on VM 3.8.4, the other is VM 3.8.8.

I cannot create a 404 error for wrong product URL, in any of the sites, no matter how hard I tried.
I always get shown the category with 200 status code.

example:

myfakesite.net/category/subcategory/myproduct1 <--- valid product link, works ok
myfakesite.net/category/subcategory/myproduct1-randomwordsshouldntwork <---- invalid product link, status code 200, shows subcategory page
myfakesite.net/category/subcategory/doesnotexist <---- invalid product link, status code 200, shows subcategory page

Things I tried:
VM 404 handling turned off (also tried enabled)
Joomla caches turned off.
Different browsers.
Different templates.

What should I try next?

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3455
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: No 404 error code on incorrect URL?
« Reply #8 on: March 23, 2021, 10:43:57 am »
Have You turned off SEF?

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

EvanGR

  • Jr. Member
  • **
  • Posts: 426
Re: No 404 error code on incorrect URL?
« Reply #9 on: March 23, 2021, 11:42:10 am »
I now tried with SEF turned off, here are the results...

This is a working product link. Works. Status code 200.
/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=95411&virtuemart_category_id=127

Same link as above, but with random letters added to product id.
/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=asddas95411aaaaaa&virtuemart_category_id=127
Expected: 404 Not Found.
Result: Works (!). Same product as before. Status code 200.

Adding a random numeric character in the product id:
/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=5asddas95411aaaaaa5&virtuemart_category_id=127
Finally, I get a 404!

So we made some progress.

Now, why does SEF never returns a 404? (we rely on SEF links on the production site)