Setting your AOM site up for mod_rewrite can be a crucial step towards making your site both more user-friendly, and search engine-friendly. But to many people, especially those without much experience, it can seem like a daunting task. We’re going to break the steps down, and make this important area look like the easy setup that it actually is.
A few notes at the beginning: the mod_rewrite feature is only available with the 30-day trial and the full (paid) versions of Associate-O-Matic. It is not available with the Lite version. And the process I’m going to outline here only works on AOM when set up on a Linux (as opposed to Windows) server. Bear in mind this has nothing to do with the operating system your computer uses, rather the system your webhost has in place to run your site. If you’re not sure, check with your webhost.
If you’re wondering what mod_rewrite can do for you, it’s simple. Let’s look at an URL with mod_rewrite off, then the same URL with mod_rewrite on:
Which one do you like better? Which one will customers and search engine spiders like better? The second link is certainly easier to read, you have a good idea what it’s about, and it looks more ‘professional’ than the link above it. The second link also seems like it would have a better chance of coming up in a Google or Yahoo! search if someone was looking for ‘Iron Man single disc edition’. This could be your site.
Okay, the first thing you’ll need is a special file called .htaccess – spelled exactly like that, with the period in front. This file goes in the same directory as your admin.php, aom.php and shop.php files. If you already have one in place, great. If not, you can create one. Some webhosts won’t let you create or upload a file without a ‘blahblah.bla’ format. If so, create the file as ‘htaccess.txt’. Then you can rename it simply as .htaccess later on.
Once you have the file in place, you need to make some decisions about what to put into it. And for that, we need to look in your AOM control panel.
Here we see the main options under the SEO tab of your control panel (I’ve turned off the descriptions to fit them all into one compact image). The first five are the most important. The first option (Mod Rewrite) simply turns the feature on or off. When we have everything set up, don’t forget to switch this to ON.
The next option is to use hyphens or underscores as the separator in the URLs that will be created. The option you select will be used between the category ID, the node (if any) and the ASIN. The title or name of the item will be in the reverse (underscore, if you select hyphen; or hyphen, if you select underscore). Like this:
- Hyphen: 7-404276-B001C08RHA-Iron_Man_Single_Disc_Edition
- Underscore: 7_404276_B001C08RHA_Iron-Man-Single-Disc-Edition
Because of the formatting required for the mod_rewrite function, you can’t have all hyphens or all underscores.
The next option is URL Home File. Whatever you pick here (the default is home) will be the internal link back to your home page, from the breadcrumb trail, the Home tab, etc. The homepage of your site will be something like www.mysite.com/home when you click on one of these internal links. If you don’t want to use anything for this link, a good option to use is ../ (yes, that’s two periods and a slash; that’s computer-talk for the main page of this site, whatever it is).
After that is URL Ends With. Your options here are either .html or nothing. Ending a URL with .html is generally seen as ‘friendlier’ in a search-engine sense than almost any other suffix. Some people may prefer not to have any sort of ending.
The last important choice is URL With Name. if You choose this option, the item or category name (where applicable) will be appended to the URL. This is another all-or-nothing selection:
The difference is obvious, as are the benefits of having the name included in your site indexing. Our final selection, URL Name Length, is not quite so important for mod_rewrite, but allows you to select the maximum character length for your URLs. If they’re too long, search engines may not like them; too short and you lose the benefit of having the name appended (if that option is chosen). The recommended length is the default setting of 200 characters.
Once you have all these options selected in your control panel (Separator, Home File, Ends With & Name; Length is not required for the next step), you need to go to this page of the Associate-O-Matic online documentation and select a Ruleset that matches your options.
For example, if you go with all the default settings:
- Separator: Hyphen
- Home File: Home
- Ends With: .html
- Name: yes
Then you would use Ruleset #1. Copy these rules and paste them into your .htaccess file. If you have a different set of options, find which ruleset matches your choices and copy & paste the corresponding ruleset into your .htaccess file.
**Important Note Number 1** If you change your Home File Name to something other than home, you must also change the second line of the ruleset you choose. If you go with the example I used (../), then change the second line to:
- RewriteRule ^../ shop.php
**Important Note Number 2** If you have changed your shop.php file name (usually people change it to index.php), you must go through the ruleset you’ve chosen and change every instance of shop.php to the name you are now using. Easy to do if you paste the rules into a text editor like Notepad and use ‘find and replace’ (don’t use Word; it adds hidden codes and things and makes it all a mess).
The important thing about the last three or four paragraphs is that the options you set in your control panel must match the rulesets you put in your .htaccess file. Once you’ve got all that, make sure you turn the Mod_rewrite feature on in your control panel and save. Save your .htaccess file.
Now, if you go to your store and refresh it, your URLs should l
ook cleaner and leaner, easier to read and easier to index. If you start getting strange errors, here are a few things to check:
- As mentioned at the beginning, make sure your site is running on Linux. Windows servers don’t work properly with .htaccess files.
- Go through your control panel SEO settings and make sure they match the ruleset you’ve pasted in your .htaccess file.
- Make sure the file really is .htaccess and not htaccess.txt or .htacess, etc.
- If you have custom URLs hardcoded into your site (like a custom homepage html section), you may need to change the URLs to match the new format. Usually this may only happen with things like category links in menus.
- If you have a pre-existing .htaccess file, there may be a conflict with any code that was added previously. If you have a command like DirectoryIndex shop.php in your file, make sure it goes above the Ruleset.
Some webhosts (GoDaddy is #1 for this) have their own strange rules for .htaccess files. The AOM forum has some suggestions for help in this area. You can also contact your webhost for assistance, or open an AOM support ticket.
Final Note: It’s recommended you set up mod_rewrite as soon as possible in the lifetime of your store. Once you do set it up, think long and hard before changing the options (and rulesets). Doing so will break any pre-existing links that may have been indexed for your site, and force you to start over from scratch in terms of search engine indexing, ranking, etc. So hopefully it will be a case of ‘set it and forget it’.