Forum Moderators: phranque

Message Too Old, No Replies

new to htaccess - problem with SEO

Seo

         

adrianicole

10:48 pm on Sep 1, 2009 (gmt 0)

10+ Year Member



I'm having a problem with the short links to my product pages (currently set back to the original to keep from hurting sales). This is probably easy but can't view the subcategory of actual product from product page. Doesn't even show bolded category of where product came from. Where do I add the category code... I've tried several variations.
Was using:
"/product/&mvta:product:code;.html"
"/category/&mvta:cattree_category:code;.html" (still using)
Both work fine but the product page will not show the subcategory or category it came from (same problem)...
htaccess is orignal inserted miva text:

RewriteEngine On
RewriteRule ^mm5/admin.mvc? - [L]
RewriteCond %{REQUEST_URI} !-s
RewriteRule ^product/([^/.]+).html /mm5/merchant.mvc?Screen=PROD&Product_code=$1 [L]
RewriteCond %{REQUEST_URI} !-s
RewriteRule ^category/([^/.]+).html /mm5/merchant.mvc?Screen=CTGY&Category_code=$1 [L]
RewriteCond %{REQUEST_URI} !-s
RewriteRule ^product/([^/]+)/([^/.]+).html /mm5/merchant.mvc?Screen=PROD&Category_code=$1&Product_code=$2 [L]
RewriteCond %{REQUEST_URI} !-s
RewriteRule ^([^/.]+).html /mm5/merchant.mvc?Screen=$1 [L]

jdMorgan

11:10 pm on Sep 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have no idea what your old (working) and new (short, not working) URLs look like, or if you were saying that this code came with Miva... but it's simply awful. It's actually quite broken.

I suspect that the third rule *should* apply to your /product/category/widget.html URLs, but can't be sure, because I don't know what your URLs look like.


RewriteEngine on
#
# Skip all rules if Miva Admin page request
RewriteRule ^mm5/admin.mvc? - [L]
#
# Skip all rules if requested URL resolves to an existing non-zero-size file
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^ - [L]
#
# Else rewrite SEO-friendly URLs to Miva script with URL-path-parts as query parameters
RewriteRule ^category/([^/.]+)\.html$ /mm5/merchant.mvc?Screen=CTGY&Category_code=$1 [L]
RewriteRule ^product/([^/.]+)\.html$ /mm5/merchant.mvc?Screen=PROD&Product_code=$1 [L]
RewriteRule ^product/([^/]+)/([^/.]+)\.html$ /mm5/merchant.mvc?Screen=PROD&Category_code=$1&Product_code=$2 [L]
RewriteRule ^([^/.]+)\.html$ /mm5/merchant.mvc?Screen=$1 [L]

I don't think that these changes will fix the problem you report, but they'll sure make it work faster and more like it was intended to work.

Please post back some example 'short' links and the 'long links' that they were supposed to go to. Please use 'example.com' as the domain name.

Jim

adrianicole

11:38 pm on Sep 1, 2009 (gmt 0)

10+ Year Member



http://www.example.com/category/CF.html (new short link)
from:
http://www.example.com/mm5/merchant.mvc?Screen=CTGY&Store_Code=CG&Category_Code=CF

http://www.example.com/product/672ELP.html (new short link that doesn't work right)
from:
http://www.example.com/mm5/merchant.mvc?Screen=PROD&Store_Code=CG&Product_Code=672ElP&Category_Code=CF

My intentions were to shorten the links & then do 301 redirects with new category names (instead of just codes) to help my overall searchability but I've been stuck with the product pages not working.
Thanks for the help.

jdMorgan

12:26 am on Sep 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> My intentions were to shorten the links & then do 301 redirects with new category names (instead of just codes) to help my overall searchability but I've been stuck with the product pages not working.

Well, you cannot do that with 'just' mod_rewrite, because mod_rewrite will have no idea how to translate the category names back to category codes. You'd have to modify Miva, put it in a script 'wrapper', or use a RewriteMap (requires server config-level access) to call a script during the URL-to-filename translation phase of the Apache API. In short, it ain't simple.

Note that for use with simple mod_rewrite rules your 'short' link URLs must agree in every respect with the required parameters in the script query string -- as to exact name spelling, capitalization, etc. Note that "ELP" is not the same as "ElP" in your example URL above.

I also noted that your rules to do not inject "Store_Code" into the query string. This may be causing some trouble. If so, then you can hard-code "&Store_Code=CG" into your RewriteRule substitutions, as long as you don't need to use any other different "store codes" with these rules. If you do, then the store code will also have to be included in the 'short' URLs.

As an example, assuming that the 'store code' is always the same, you'd end up with this after adding the store code to the second 'product' rule in my post above:


RewriteRule ^product/([^/]+)/([^/.]+)\.html$ /mm5/merchant.mvc?Screen=PROD[i]&Store_Code=CG[/i]&Category_code=$1&Product_code=$2 [L]

If you then request the short URL example.com/product/CF/672ElP.html, the request will be passed to your script as /mm5/merchant.mvc?Screen=PROD&Store_Code=CG&Category_Code=CF&Product_Code=672ElP

Your example of the 'non-working URL' above doesn't work for two reasons: First, the product name in the short URL is mis-capitalized and second, the category is missing from the short URL and so cannot be passed to your script by the second 'product' rule (it will instead match the preceding 'product' rule, which does not pass categories -- If you ask for the short URL example.com/product/[/b]/672ElP.html, then the request will be passed to your script as /mm5/merchant.mvc?Screen=PROD&Product_Code=672ElP by the first 'product' rule in my post above). As mentioned, a third reason may be because the store code is missing from the substitution query string.

Jim

wyweb

12:29 am on Sep 2, 2009 (gmt 0)



jdMorgan, you continue to amaze me....

adrianicole

1:51 am on Sep 2, 2009 (gmt 0)

10+ Year Member



You have no idea how much time you just saved me. I would have been looking forever on trying to figure out those redirects!
I've had my fill already with my current project.
I made the changes to my htaccess file. Thank you for that.
I changed the second product rule (third rule down) to the new one with the store code in it. I then tried to make new rule on my product display page that listed it exactly the way your example shows up:
“/product/&mvta:category:code;/&mvta:product:code;.html"
Somehow it isn't pulling up the product page. I even put in the store code & tried it that way so I've still got something wrong. In fact, the product rule that worked before is now not working in my miva pages(even before I made the changes to my htaccess file). I think I'll have to take a fresh look at it tomorrow.
Thank you so much again. It's great how you help people.

Marcia

1:54 am on Sep 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are modules for Miva 5 that deal with the URL issues to make them "pretty" and SEO friendly. I've had two Miva developers suggest to me (on the phone) that it's best to have the module developer install their modules, since if there are any issues they know the code. Having long dealt with (wept over) multiple MIVA peculiarities and SEO issues, I couldn't agree more.

In MM4 there's an option to have the page H1 duplicate the page titles, which I assume is also available in MM5. Not a particularly good idea, IMHO; it's best to have them vary slightly.

Other things to watch for are title/description duplications due to pagination issues, and sometimes there's more than one URL path to individual products. It's a good idea to have Google Analytics and Webmaster Tools enabled to check for duplications - and for 404's (mostly from bots hitting the cart link).

Added:

/mm5/merchant.mvc?

Just a FYI: that's how all the "referrals" from pages to the homepage show in Analytics, for the entire shopping cart.

adrianicole

4:36 pm on Sep 2, 2009 (gmt 0)

10+ Year Member



Thanks for the additinal information Marcia! These are all items I haven't used previously & can use all the help I can get.