News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

No 404 error code on incorrect URL?

Started by EvanGR, March 22, 2021, 14:36:17 PM

Previous topic - Next topic

EvanGR

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

QuoteVM 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 https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

EvanGR

#2
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

QuoteEDIT: 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 for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

EvanGR

Quote from: pinochico on March 22, 2021, 15:09:49 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

www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Jörgen

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

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

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

EvanGR

#9
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)