[Zen Cart] URLs in shopping cart: products with attributes

Magic SEO URLs for Zen Cart.
capnhairdo
Posts: 5
Joined: Tue Mar 25, 2008 5:30 pm

[Zen Cart] URLs in shopping cart: products with attributes

Postby capnhairdo » Tue Mar 25, 2008 5:37 pm

Just noticed a problem with our installation of MSEO...links from our shopping cart to product pages for products with attributes don't work:

Unmodified ZenCart link:
babybestbuy.com/index.php?main_page=product_info&products_id=509:557e3599b708fca63da8e288884c76c2

With MSEO becomes:
babybestbuy.com/chamois-chenille-changing-table-cover-509%3A557e3599b708fca63da8e288884c76c2.html

Note the appended colon and number string on the end of the product_id in the links (which seem to tell ZenCart which attributes to select by default when you return to the product page). This ONLY happens with products that have attributes. Seems MSEO isn't handling this extra string correctly and the links are breaking. Products without attributes don't have the extra number string appended and the links work fine.

This could be some problem with my particular installation of MSEO, but thought I should ask. Anybody else experiencing this? This isn't a mod_rewrite thing since these are links that are automatically rewritten by MSEO when the page is loaded, which is part of the MSEO core. Any insight would be appreciated.

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [Zen Cart] URLs in shopping cart: products with attributes

Postby inveo » Tue Mar 25, 2008 5:57 pm

Such URIs are handled by MSU correctly with following Rewrite Rule (single language mode):

Code: Select all

#product_info - product info (no-category)
RewriteCond %{QUERY_STRING} ^currency=([a-zA-Z]{3})&zenid=([a-z0-9]*)$ [OR]
RewriteCond %{QUERY_STRING} ^currency=([a-zA-Z]{3})$ [OR]
RewriteCond %{QUERY_STRING} ^zenid=([a-z0-9]*)$ [OR]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^([a-z0-9\-]*)-([0-9a-z:]*).html$ index.php?main_page=product_info&products_id=$3&language=$1 [L,QSA]

I think the problem is caused by old Apache (with mod_rewrite, which does not work correctly with some RegExp), because your web server is running on Debian. Please ask your web host or administrator for installing latest Apache version.
You can also test this behavior at http://www.magic-seo-url.com/demo/zencart/ to prove my sense.

Btw If crawler finds such link with attributes, then is redirected to URI with no attributes to prevent any duplicate content penalization.

capnhairdo
Posts: 5
Joined: Tue Mar 25, 2008 5:30 pm

Re: [Zen Cart] URLs in shopping cart: products with attributes

Postby capnhairdo » Tue Mar 25, 2008 6:41 pm

Code: Select all

Such URIs are handled by MSU correctly with following Rewrite Rule

So you're saying it is in fact rewrite rules. Why is MSEO converting the colon to %3A in the modified address? Seems like it should just leave it alone. But you're right, works fine regardless on your test store.

Code: Select all

RewriteRule ^([a-z0-9\-]*)-([0-9a-z:]*).html$ index.php?main_page=product_info&products_id=$3&language=$1 [L,QSA]

This code you supplied is not the same as I have in my .htaccess file generated by MSEO 1.101. I have:

Code: Select all

RewriteRule ^([a-z0-9\-]*)-([0-9a-z:]*).html index.php?main_page=product_info&products_id=$2 [L,QSA]

Which I believe is correct since I see no reference to a language component in the URL, and the products_id does in fact seem to be the second matching subpattern, not the third.
I think the problem is caused by old Apache (with mod_rewrite, which does not work correctly with some RegExp), because your web server is running on Debian.

So are you saying that MSEO is not compatible with slightly older versions of Apache? I don't remember seeing that listed in any system requirements for the product.
Please ask your web host or administrator for installing latest Apache version.

This is hardly a viable request. They're not going to change the hosting software for my entire shared server just because I ask. Nor do I see why I need to ask them to make this change to accommodate a small regex problem with MSEO.

Anyway, if it is mod_rewrite, then it should be an easy fix. The change below seems to work—simply moving the colon to the beginning of the subpattern, rather than the end:

Code: Select all

RewriteRule ^([a-z0-9\-]*)-([:0-9a-z]*).html index.php?main_page=product_info&products_id=$2 [L,QSA]

This also works, which I think is more rigorous as it specifically identifies the attribute string apart from the product id:

Code: Select all

RewriteRule ^([a-z0-9\-]*)-([0-9]*)(:[0-9a-z]*)?.html index.php?main_page=product_info&products_id=$2$3 [L,QSA]

Please verify that these are correct and work and if so, I suggest you update the next version of MSEO to integrate these changes so that it works on older Apache servers.

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [Zen Cart] URLs in shopping cart: products with attributes

Postby inveo » Wed Mar 26, 2008 3:46 am

capnhairdo wrote:So you're saying it is in fact rewrite rules. Why is MSEO converting the colon to %3A in the modified address?

It have to be converted when it is not part of query string. Otherwise it not work with some browsers.

capnhairdo wrote:Which I believe is correct since I see no reference to a language component in the URL, and the products_id does in fact seem to be the second matching subpattern, not the third.

Yes it is correct (I only forget to remove language from Rewrite Rule - originally I took RewriteRule from multi-language installation).

capnhairdo wrote:So are you saying that MSEO is not compatible with slightly older versions of Apache? I don't remember seeing that listed in any system requirements for the product.

It can not be listed since mod_rewrite has no version (it is part of Apache). It is good practise to use latest Apache 1.x, 2.x or 2.2.x, not manually patched like Debian packages are.

capnhairdo wrote:Anyway, if it is mod_rewrite, then it should be an easy fix. The change below seems to work—simply moving the colon to the beginning of the subpattern, rather than the end:

Code: Select all

RewriteRule ^([a-z0-9\-]*)-([:0-9a-z]*).html index.php?main_page=product_info&products_id=$2 [L,QSA]

This also works, which I think is more rigorous as it specifically identifies the attribute string apart from the product id:

Code: Select all

RewriteRule ^([a-z0-9\-]*)-([0-9]*)(:[0-9a-z]*)?.html index.php?main_page=product_info&products_id=$2$3 [L,QSA]

Please verify that these are correct and work and if so, I suggest you update the next version of MSEO to integrate these changes so that it works on older Apache servers.


Thanks for patch, will be tested and added to development tree soon.

inveo
Inveo Support
Posts: 1285
Joined: Sat Feb 02, 2008 12:07 pm
Contact:

Re: [Zen Cart] URLs in shopping cart: products with attributes

Postby inveo » Sun Mar 30, 2008 4:23 am

Magic SEO URL for Zen Cart 1.1.02 was released and also fixes this issue.