Forum Moderators: phranque
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]
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
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.
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]
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
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?