Web business consultants

How to create short URLs in MM5

MIVA Merchant 5 Short URLs

This is a step by step guide to creating short links, i.e. search engine friendly, for MIVA Merchant 5 webstores hosted on Apache HTTP servers, typically on Linux boxes. It involves the creating a file which calls the mod_rewrite functions in Apache. If your store is hosted on a Windows IIS server, click here.

So for example, we want to make our link to our Coyote Torolla CE Automatic 2006 product page, from the Torolla Category page, look like this:

http://www.ourdomain.com/pc/TorCeA6/Torolla/Coyote_Torolla_CE_Automatic_2006

instead of this:

http://www.ourdomain.com/mm5/merchant.mvc?Screen=PROD&Product_Code=TorCeA6&Category_Code=Torolla&Store_Code=OurDomain

Creation of search engine friendly links for MM5 is a two stage process:

  1. creation of a .htaccess file which contains the mod_rewrite instructions, uploading it to the server and
  2. writing the search friendly links in the Category Tree (cattree) and on the Category (CTGY), Product (PROD), Product List (PLST) and Search (SRCH) pages

With MIVA Merchant 5, you don't need to buy and install a special search friendly links module as was required for MIVA Merchant 4 (i.e. Copernicus' "Search Friendly Links" or Pixel Composer's SEO Links). This is because with MIVA Merchant 5 you write the search friendly links yourself into each of the Page templates. However, the MIVA Page templates do not give you access to the Category Tree so you will need to purchase a Category Tree module if you wish to use search friendly links in the Category Tree (which you should). Of course, Weiland's or Sebenza's Category Tree modules also give you full design control over the Category Tree so we consider the purchase of either of these modules to be essential for any MM5 store. Both are very reasonably priced.

The pages you should be trying to get listed highly in search engines are your product and category pages and so links to those pages are the ones to make search engine friendly.

Search engines are wary of dynamically generated pages because they can create problems for their robots and due to the probable creation of duplicate pages which lessens the relevancy of their search results. The normal MIVA links are long and contain parameters (e.g. the question mark: ?) which alert search engine robots that these pages are created dynamically. Search engines react to these in a variety of ways including:

  • not following the link at all (i.e. not crawling the page)
  • following the link on a delayed basis (e.g. assigning it a crawl date for 12 months later)
  • assigning a penalty to the crawled page (e.g. multiply the total page score by 0.6) when indexing it
  • crawling the page but excluding it from it's index (either permanently or on a delayed basis e.g. assigning it an indexing date for 12 months later

Thus, our objective is to create links that search engines will both follow and not penalize.

There are five types of MIVA Merchant links that you should make search engine friendly:

  • to a category page, from the category tree*
  • to a category page, from a category page**
  • to a product page, from a category page
  • to a product page, from the product list page
  • to product and/or category pages, from custom pages that you create

*    requires the installation of a Category Tree module
**  requires the installation of a Category Tree module which offers the use of links to sub categories on "parent" category pages

After you have created the search engine friendly links you will note that they display that way to all visitors - search engine robots included.

So, our first step is to create the .htaccess file. This file contains the instructions that the Apache module known as "mod_rewrite", executes to rewrite your short URLs into the MIVA Merchant long URLs.

.htaccess File Tips, Tricks and Traps

First, a few important pointers about the .htaccess file:

  • The .htaccess file which you will create, should be uploaded to the directory on the server which contains the mm5 directory. On your server, this could be either /httpdocs/ or /html/ e.g.
Directory for the .htaccess file
  • Before you begin, check to see if there is already a .htaccess file in that directory. If there is, download it and make your changes to it (NB: keep a backup copy of the original. In fact keep multiple backup copies of the original! Also, print a copy of the original). If you get the commands in the .htaccess file even just slightly wrong, it will probably cause major problems with your store. Having a backup that you can instantly upload to your /httpdocs/ or /html/ directory will ensure your store is down only for a minute or two. Then, you can troubleshoot "your" .htaccess file while your store continues to operate normally.
  • NB: You may not be able to see an existing .htaccess file in the /httpdocs/ (or /html/) directory. Reason: those files are hidden files. As can be seen from the left image, the file does not show, yet it exists. By adding "-la" in the white box (using WS FTP Pro as the FTP software), then "refreshing the page" by moving to the mm5 directory and then back up to the httpdocs directory, the .htaccess file now appears (see image on right). It is important you locate, copy, then modify (for our .htaccess changes) an existing .htaccess file and not accidentally destroy an existing .htaccess file by copying a new one over it.
.htaccess file is hidden .htaccess file is visible
  • The .htaccess file in any directory affects the files in that directory. There may be multiple .htaccess files on your server, each located in a different directory. The only .htaccess file we need to be concerned with is the one already existing in the /httpdocs/ or /html/ directory or, if one currently doesn't exist, the one we will create and upload to that directory. Leave any others you see, alone.
  • The .htaccess file is created/edited in a text editor e.g. Notepad and is saved without an extension. That is, the correct file name is: .htaccess . It is NOT: .htaccess.txt  .  To save the file without an extension in Notepad, under "Save as type", select "All Files".
  • the .htaccess file is uploaded to the server via FTP or, on some servers, via Telnet
  • .htaccess must be uploaded in "ASCII mode", not in "binary mode". Thus, configure the "Transfer mode" of your FTP software to either "ASCII" or "Auto Detect"
  • Contrary to what you might expect, the .htaccess file and mod_rewrite convert/rewrite the short URLs to the long MIVA Merchant URLs (which Merchant 5 "sees"), not the other way around. You need to keep this in mind when you are examining the code suggested below, for the .htaccess file - it will make more sense.

mod_rewrite Tips, Tricks and Traps

  • mod_rewrite is an Apache module which enables URL rewriting e.g: rewriting from:
    http://www.yourdomain.com/pc/TorCea6/Torolla/Coyote_Torolla_CE_Automatic_2006    to:
    http://www.yourdomain.com/mm5/merchant.mvc?Screen=PROD&Product_Code=TorCea6&Category_Code=Torolla&Store_Code=Domain
  • Back-references from RewriteRule to RewriteCond only apply to the last-matched RewriteCond< (see "1. Link to a Category from the Category Tree" below, for an example of the importance of this)

1. Create the .htaccess file

To create your .htaccess file:

  1. Open Notepad and create a new file
  2. Copy and paste the code below into the file
  3. Save the file - click on File | Save, then "Save as type" and click on "All Files" and Encoding "ANSI" then give the file the name of ".htaccess"

Options +FollowSymlinks
RewriteEngine On
# 
RewriteCond %{REQUEST_URI} ^/p/(.*)/(.*)	[NC] 
RewriteRule (.*) /mm5/merchant.mvc?Screen=PROD&Product_Code=%1&Store_Code=ZZ [L]
RewriteCond %{REQUEST_URI} ^/pc/(.*)/(.*)/(.*)	[NC]
RewriteRule (.*) /mm5/merchant.mvc?Screen=PROD&Product_Code=%1&Category_Code=%2&Store_Code=ZZ [L]
RewriteCond %{REQUEST_URI} ^/c/(.*)/(.*)	[NC] 
RewriteRule (.*) /mm5/merchant.mvc?Screen=CTGY&Category_Code=%1&Store_Code=ZZ [L]

What does all this mean?

Options +FollowSymlinks must be enabled for the rules to work. Normally it's enabled in the root directory so you shouldn't have to add it, but it doesn't hurt to do so, even if is enabled in the root.
RewriteEngine On instructs Apache to enable the mod_rewrite function
# start of a comment. In the .htaccess file above it is just being used as a spacer
RewriteCond defines a rule condition
% defines a variable that comes from a rewrite condition
{REQUEST_URI} the URI given in order to access the page
^ the start of a string
/p/ the "term" we have used to denote a link that does not contain the Category Code, to a product page e.g from the PLST page to a product page. The slashes "/" are separators
/pc/ the "term" we have used to denote a link containing the Category Code, to a product page e.g from a CTGY page to a product page. The slashes "/" are separators
/c/ the "term" we have used to denote a link to a category page e.g from the category tree to a product page. The slashes "/" are separators
( ) the parentheses which enclose an expression
. (i.e. a dot) matches any single character, except the ending of a line
* matches anything in the string immediately preceding it as many times as it can. Note that as this is a less efficient directive, it is better to use a more detailed one (using the commands in the last 4 rows of this table) - this will be the subject of another tutorial which will be completed later in the year. For the moment, stick with the asterisk (*) - it will do the job.
[NC] 'No Case' as applied to letters, so if you use this on a rule, OurDomain.com, will match ourdomain.com, even though they are not the same
RewriteRule defines how the URL is to be rewritten
[L] Last Rule. This 'flag' or directive tells Apache to stop processing - that this is the end of this RewriteRule.
ZZ Replace the "ZZ" with your Store_Code
$ the end of a string
+ matches 1 or more of the characters or set of characters immediately before it. (e.g. a+ would match the lowercase letter 'a' 1 or more times, while [a-z]+ would match 1 or more lowercase letters from 'a to z')
a-z letter-letter (e.g. [a-z] matches any single lowercase alphabetical character in the range of a to z), so [c-e] will match any single character that is the lowercase letter c, d, or e.
A-Z LETTER-LETTER (e.g. [A-Z] matches any single capital alphabetical character in the range of A to Z), so [C-E] will match any single character that is the capital letter C, D, or E.
0-9 number-number (e.g. [0-9] matches any single number in the range of 0 to 9), so [3-7] would match any single number 3, 4, 5, 6 or 7

Note that the example code above assumes you are not using a Mall. If you are creating links for a store in a Mall, then some additions need to be made to the above code. This will be the subject of another tutorial, to be completed later in the year. In the meantime, you can contact us for details.

2. Replacing the MM5 links with your search engine friendly links

The example links below were based on the following:

Domain 127.0.0.1:8000 (i.e. the examples were created in MIVA Mia)
Category Code (1) Aud_Vis
Category Name (1) Books Tapes and DVDs
Product Code Adv_Sales
Product Name Advanced Sales Seminar
Category Code (2) Semin
Category Name (2) Seminars
Store Code Develop

1. Link to a Category from the Category Tree

There are two Category Tree modules currently available and the required links are different for each of them.

(a) Sebenza's Category Tree template:

  • Go to "Edit Store: Your Store Name" in MIVA Admin and then click on "Category Tree Template"
  • Replace:
    <a href="&mvt:global:sessionurl;Screen=CTGY&Store_Code=&mvta:store:code;&Category_Code=&mvta:tree:code;" class="&mvt:tree:class;">&mvt:tree:name;</a>
    with:
    <a href="/c/&mvta:tree:code;/&mvta:tree:name;.html" class="&mvt:tree:class;">&mvt:tree:name;</a>

(b) Weiland's My Category Tree:

  • Go to "Edit Store: Your Store Name" in MIVA Admin and then click on "My Category Tree"
  • Replace the original code with the "Tree Example" sample code found here: http://www.emporiumplus.com/v5/mytree_example.txt
  • Note that if your Page templates retain the standard BaseURL item (<base href="&mvt:global:basehref;">) then you should not include the domain in each link, as the Tree Example shows. So, e.g. replace this in the Weiland sample:
    <a href="http://www.yourdomain.com/c/&mvta:child1:code;/&mvta:child1:name;.html"><u>&mvt:child1:name;</u></a>
    with:
    <a href="/c/&mvta:child1:code;/&mvta:child1:name;.html">&mvt:child1:name;</a>
    - you need to do this for each link.

It looks more complex to create the search engine friendly links with the Weiland My Category Tree than it actually is. Just copy the Tree Example then make that minor change to each link.

This is how your search engine friendly link will display (see bottom of image):

Search engine friendly link to a category

compared to how the original MIVA Merchant link displays (see bottom of image):

MIVA Merchant standard link to a category

Note: The standard MIVA Merchant link contains only the Screen Name, Store Code and Category Code - i.e. we have added the category name to the search engine friendly link. You will note that the .htaccess file makes no mention of the category name nor does it include the extension ".html" so how is this possible? It is due to a feature of mod_rewrite that ignores the last rule if it doesn't "match" the condition.

2. Link to a Product from a Category (CTGY) screen

  • Go to "Pages" in MIVA Admin, click the Edit button for the "CTGY" template then click on "Category Product List Layout"
  • Replace:
    <a href=
    "&mvt:global:sessionurl;Screen=PROD&Store_Code=&mvta:store:code;&Product_Code=&mvta:product:code;
    &Category_Code=&mvta:category:code;">&mvt:product:name;</a>

    with:
    <a href="/pc/&mvta:product:code;/&mvta:category:code;/&mvta:product:name;">&mvt:product:name;</a>

This is how your search engine friendly link will display (see bottom of image):

Short URL to a product page from a category page

compared to how the original MIVA Merchant link displays (see bottom of image):

MIVA Merchant standard URL to a product page from a category page

Note: The standard MIVA Merchant link contains only the Screen Name, Store Code, Product code and Category Code - i.e. we have added the product name to the search engine friendly link. You will note that the .htaccess file makes no mention of the product name. This is possible due to a feature of mod_rewrite that ignores the last rule if it doesn't "match" the condition.

3. Link to a Product from the Product List (PLST) screen

This is how your search engine friendly link will display (see bottom of image):

Search engine friendly link to a product page from the Product List

compared to how the original MIVA Merchant link displays (see bottom of image):

MIVA Merchant standard link to a product page from the Product List

Avoid Costly Mistakes & Hassles

We continue to get work fixing up stores whose owners have tried implementing search engine friendly links using either Sebenza's Ultimate SEO Links or other modules or following the tutorials above and failing to do so completely and/or correctly.

Consequences: Search engines fail to index your site the way you want (even when you submit pages and have Google site maps). Consequences of that: you lose your traffic and it takes many months to get back even if we fix it for you but you may never get it back it the mistakes remain unfixed.

So, avoid the mistakes in the first place - we can create search friendly links for you for a cost of between $265 - $395 approx. If you have the Sebenza module installed, the price will be at the lower end of the scale and your links will be slightly better (slightly shorter).

We can create them in your choice of formats, including:

  • as per the Sebenza Ultimate SEO Links module - including the product and category names
  • as per the tutorial above - including the product and category names
  • as per your existing MM4 Copernicus Search Friendly Links
  • as per your existing MM4 Pixel Composer SEO Links
  • another format that you may prefer

Just contact us and let us know what you need and we'll give you a firm price.

Note: The standard MIVA Merchant link contains only the Screen Name, Store Code and Product Code (the Category Code is blank because the link originates from the PLST page, not a category page) - i.e. we have added the product name to the search engine friendly link. You will note that the .htaccess file makes no mention of the product name. This is possible due to a feature of mod_rewrite that ignores the last rule if it doesn't "match" the condition.

We are trying to make this Search Engine Friendly links for MIVA Merchant 5 tutorial as useful as possible. Please let us know of any errors, omissions or unclear instructions.

Also, use our free search engine page optimization tool to see how your MIVA Merchant store pages look to search engines. Feel free to use it to help improve your rankings. Just copy the complete URL to any of your product or category pages into the Analyzer "http://" box and that page will be analyzed for you. Test as many pages as you like or as often as you like (e.g. after you have made changes).

Finally, if you have created custom pages and wish to also create search engine and visitor friendly URLs to custom pages in MIVA Merchant 5, click here.

Internet Marketing Engine - Web business consultants to small & mid-size organizations
Privacy and Security

Phone: Chicago +1 (708) 401-0421 or Melbourne, Australia +61 (3) 9670-1165

Copyright © 2000-2008 Internet Marketing Engine Australia USA. All rights reserved.

Get better rankings for your product and category pages:About Us|Contact Us|Site Map|Home