VirtueMart Forum

VirtueMart 2 + 3 => Administration & Configuration => Topic started by: EvanGR on March 22, 2021, 14:36:17 pm

Title: No 404 error code on incorrect URL?
Post by: EvanGR 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]
Title: Re: No 404 error code on incorrect URL?
Post by: GJC Web Design 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
Title: Re: No 404 error code on incorrect URL?
Post by: EvanGR 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.
Title: Re: No 404 error code on incorrect URL?
Post by: pinochico 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.
Title: Re: No 404 error code on incorrect URL?
Post by: EvanGR 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.
Title: Re: No 404 error code on incorrect URL?
Post by: pinochico on March 22, 2021, 17:37:15 pm
hmmm :(
Title: Re: No 404 error code on incorrect URL?
Post by: Jörgen on March 22, 2021, 17:55:54 pm
Emptied cache in Your browser, using Chrome perhaps ?

Jörgen
Title: Re: No 404 error code on incorrect URL?
Post by: EvanGR 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?
Title: Re: No 404 error code on incorrect URL?
Post by: Jörgen on March 23, 2021, 10:43:57 am
Have You turned off SEF?

Jörgen
Title: Re: No 404 error code on incorrect URL?
Post by: EvanGR 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)