Author Topic: No 404 error if VirtueMart is set as home page  (Read 10809 times)

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
No 404 error if VirtueMart is set as home page
« on: October 01, 2013, 10:07:52 am »
I have tried this on a couple of sites with VM 2.0.22 with the same behaviour. I have also been able to reproduce it on a test site created with shops.virtuemart.net.
If you set VirtueMart as your default menu item, 404 will not work anymore: calling a non existant URL will redirect you to URL with a 303 code.

Steps to reproduce:
* set VirtueMart as default menu item
* in Joomla SEO Settings, enable both "Search Engine Friendly URLs" and "Use URL rewriting"
* now if you call any fake address, e.g. www.example.com/non-existant-link, it will issue a 303 to the home page instead of a 404.

I have no SEF extensions installed.

Anyone else can confirm the issue?

--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: No 404 error if VirtueMart is set as home page
« Reply #1 on: October 01, 2013, 10:38:43 am »
I have found a possible fix. In /components/com_virtuemart/virtuemart.php, line 111, i changed from:

Code: [Select]
    $mainframe->redirect(JRoute::_ ('index.php?option=com_virtuemart&view=virtuemart', FALSE));

to

Code: [Select]
    JError::raise(E_ERROR,'404','Not found');
    $mainframe->close();

This seems to do the trick.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3377
  • using Matomo instead of Google Analytics
Re: No 404 error if VirtueMart is set as home page
« Reply #2 on: October 01, 2013, 11:06:25 am »
Hi Francesco,

That's "normal". We've discussed that several times.
1. It's a good "feature" from the user's point of view, because if he clicks on a wrong or outdated url (maybe indexed by a search engine), showing him the homepage from where he can search for the information he wants to see, is better than the non-informative "404 - page doesn't exist" (you might loose a potential customer).
2. Search engine crawlers like those from Google of course prefer to get a 404 page. But if Google's crawlers find (for example an outdated external link to your site) or generate a non-existant url , their algorithms are configured to drop it from the index after some time anyway.

Personally I think that the user experience should have priority. VM 2.0.24 comes with some 'noindex, nofollow' added to the code in order to keep crawlers to 'invent' urls which are not regular SEF urls derived from the menu structure.

A typical case is this:
A few months back you had this url pointing to a specific product: yourdomain.com/enter-shop/category-name/product-name-detail
Then you changed your mind and renamed your menu item 'enter-shop' to 'gallery', so your new url is yourdomain.com/gallery/category-name/product-name-detail. You submitted the new url to the search engines or the search engines picked up the new url themself. Now both urls might be indexed for a while, and because the way VM works, both the old and the new url will display the correct page to the customer instead of throwing a 404 error in case of the old url. However, because the VM product page also includes the new canonical url, the search engines will drop the old url sooner or later and will (should) not re-index the old url.



Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Wibah

  • Beginner
  • *
  • Posts: 4
Re: No 404 error if VirtueMart is set as home page
« Reply #3 on: October 07, 2013, 23:53:47 pm »
One little sidenote though...

Manually added 301 redirects in your .htaccess file or Joomla redirect component won't execute because of this.
So for example, if you want to manually redirect old URLs to your new URLs you've got a bit of an issue. Hence the user will be redirected to the homepage instead of being redirected to your specific page.
After Zanardi's possible fix it does redirect correctly to your specific links. And gives other non-existant URL's a 404 error page.

So I guess you've got to chose the best way for yourself.

OpenGlobal

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 316
    • OpenGlobal E-commerce Web Design in Gloucester
Re: No 404 error if VirtueMart is set as home page
« Reply #4 on: December 20, 2013, 17:09:48 pm »
1. It's a good "feature" from the user's point of view, because if he clicks on a wrong or outdated url (maybe indexed by a search engine), showing him the homepage from where he can search for the information he wants to see, is better than the non-informative "404 - page doesn't exist" (you might loose a potential customer).

It may be a good feature in general, but in Joomla, it's incorrect behaviour. Joomla has the template error.php AND the Redirect component so that users can configure how they want errors to be reported/ignored. Hijacking these options in VirtueMart to circumvent intend CMS behaviour is wrong. At best, it should be a configurable option in VM.

OpenGlobal E-commerce

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: No 404 error if VirtueMart is set as home page
« Reply #5 on: January 05, 2014, 22:57:08 pm »
Thanks @Wibah and @OpenGlobal, you have expressed exactly my thoughts.
I also do care about user experience, but:
* this is not VirtueMart job
* and if it is, it should be a more flexbile solution (not breaking other redirects)

I am happy to see that it's been fixed in SVN (now it's a configurable option).
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

Martyn Batten

  • Jr. Member
  • **
  • Posts: 140
Re: No 404 error if VirtueMart is set as home page
« Reply #6 on: January 31, 2014, 11:33:52 am »

I am happy to see that it's been fixed in SVN (now it's a configurable option).

Has anybody tested this, as there is no difference whether it is enabled or not..

I use VM 2.0.26d with Joomla 2.5.17

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: No 404 error if VirtueMart is set as home page
« Reply #7 on: February 03, 2014, 20:06:14 pm »
@spike1968:
it's working fine for me. Remember to enable the "Redirects" plugin and the specific redirect rule.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

Martyn Batten

  • Jr. Member
  • **
  • Posts: 140
Re: No 404 error if VirtueMart is set as home page
« Reply #8 on: February 04, 2014, 11:32:46 am »
@spike1968:
it's working fine for me. Remember to enable the "Redirects" plugin and the specific redirect rule.

All set up correctly and still not working.

keclap

  • Beginner
  • *
  • Posts: 3
Re: No 404 error if VirtueMart is set as home page
« Reply #9 on: March 13, 2014, 13:40:05 pm »
It is also not working for me, no difference when 'Enable VirtueMart 404 error handling' is checked or not.

In fact, I can't get VirtueMart to throw 404 error when it should. Other components display 404 page correctly, but VM simply falls back to parent item in some cases. Examples (simplified):
www.mysite.com/category/dummy-error -> shows www.mysite.com/category instead of 404 page
www.mysite.com/category/product/dummy-error -> shows 404 page correctly
www.mysite.com/account/edit/dummy-error -> shows www.mysite.com/account/edit instead of 404 page

Joomla! 2.5.18, VM 2.0.26d

Anybody has any clue?

Thanks!
Jan

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27105
  • Always on vacation
    • Jenkin Hill Internet
Re: No 404 error if VirtueMart is set as home page
« Reply #10 on: March 13, 2014, 15:08:50 pm »
Working OK on the next version to be released soon. Or try VM2.5.2 - but not on a live site yet.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.3.9989 on Joomla 3.9.1 PHP 7.0.32
Testing VM 3.4.3.9993 on Joomla 3.9.1

Martyn Batten

  • Jr. Member
  • **
  • Posts: 140
Re: No 404 error if VirtueMart is set as home page
« Reply #11 on: March 13, 2014, 15:32:43 pm »
Thanks for keeping us informed  :)

keclap

  • Beginner
  • *
  • Posts: 3
Re: No 404 error if VirtueMart is set as home page
« Reply #12 on: March 13, 2014, 16:36:52 pm »
Thanks for good news. I'm getting ready to test 2.5.2 - will report back when I'm done.

Jan

keclap

  • Beginner
  • *
  • Posts: 3
Re: No 404 error if VirtueMart is set as home page
« Reply #13 on: March 13, 2014, 18:13:23 pm »
Unfortunately version 2.5.2 makes no difference.

Error is handled correctly only when product's url is mistyped (like www.mysite.com/category/product/dummy-error) - the same as in current stable version 2.0.26d.
But I am still redirected to upper category when I mistype the the category: www.mysite.com/category/dummy-error -> shows www.mysite.com/category instead of 404 page

Since 404 displays correctly in case of a product, can this behaviour be applied to category as well? Where in code should I start searching?

Thanks for all suggestions!
Jan

d0ublezer0

  • Jr. Member
  • **
  • Posts: 178
Re: No 404 error if VirtueMart is set as home page
« Reply #14 on: August 10, 2018, 08:30:27 am »
Problem is still here, VirtueMart 3.2.12
if VM set as homepage - no 404 error
and it does not matter whether the 404-hanlking option is enabled or disabled