News:

Looking for documentation? Take a look on our wiki

Main Menu

No 404 error if VirtueMart is set as home page

Started by zanardi, October 01, 2013, 10:07:52 AM

Previous topic - Next topic

zanardi

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

I have found a possible fix. In /components/com_virtuemart/virtuemart.php, line 111, i changed from:


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


to


    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

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

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

Quote from: jjk on October 01, 2013, 11:06:25 AM
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

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

Agaton

Quote from: zanardi on January 05, 2014, 22:57:08 PM

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

@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

Agaton

Quote from: zanardi 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.

All set up correctly and still not working.

keclap

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

Working OK on the next version to be released soon. Or try VM2.5.2 - but not on a live site yet.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

Agaton


keclap

Thanks for good news. I'm getting ready to test 2.5.2 - will report back when I'm done.

Jan

keclap

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

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