The concept is fairly simple. Make your website’s urls as readable as possible. If a human can read and remember the url, then you can bet your bottom dollar that search engines can as well. And THAT is the best way to approach this. If YOU can remember the url easily, then you have succeeded. If the url contains a huge query string with a lot of parameters that a person with an eidetic memory would have trouble memorising, then the search engines will have trouble following the links, you will lose rankings and that is bad for any seo campaign.
An example of a bad url is: http://www.example.com/index.php?p=156&c=55
An example of a good url is: http://www.example.com/category-name/product-name
How do we fix it?
This requires a lot of planning, and should be considered during the development of the site. In this example, we shall use a /file-name, /category-name/, /category-name/product-name approach. Basically, if there is sub-directory and no trailing slash, then treat the url as a file name. If there is a subdirectory, treat it as a category name, and if there is another section of the url then treat that as the product name.
There is a major problem with using a url structure like this, and that is having two or more categories or products with the same name. For this to work properly, each category must have it’s own name and each product within each category must have it’s own unique name.
In order to fix this we will need a little help from our old friend, the .htaccess file. I’ll show the code first, then dissect it.
RewriteRule (.*)/(.*) index.php?c=$1&p=$2
RewriteRule (.*)/ index.php?c=$1
RewriteRule (.*) index.php?page=$1
The first line is telling the server to enable the mod_rewrite module. Without this, none of the following rewrite rules would work.
With me so far? The rest of the code gets a little more complicated. I’ll explain what each of the symbols is doing on it’s own, in context, and the end result. Hopefully this will allow you to make changes in the future as you need to.
There are thousands of tutorials on how to write regular expressions so I won’t go into very much detail here about everything. Consider this the basic of basics in order to accomplish a rather specific task.
In regular expression the period / dot – . – means any character except a new line. This is part of a group of commands called Ranges. They specify what to select, for example only select lower case letters, or some letters but not others, or only numbers, or only upper-case letters. This symbol will fetch ANY character, but only one, so we need to tell it to get as many characters as there are. We do this by using the asterisk / star – * -. This symbol is referred to as a Quantifier. A quantifier, as you may guess from it’s name, tells the expression how many of the range to get. This symbol means get 0 or more of the range. Putting it together, we get ‘Get 0 or more occurrences of ANY character’. Finally, the parenthesis (the brackets) mean ’save this content / group’. It saves the content in the format of $n, where n equals the number of groups that have been saved. As an example, in the line (.*)/(.*) will give us two groups of $1 and $2. These can then be used later in the expression.
With the basics covered, we’ll explain what each line is doing:
The second line is telling the server to separate everything before and after the slash and save them as variables $1 and $2 (respectively). It then loads the index.php file passing in the variables as part of a query string, where $1 is the category and $2 is the product.
The third line is fetching just everything before the slash as the category, and the final line is fetching everything as a page (for example a site-map or a terms and conditions page or some other information-based page).
It may look complicated but it really is quite simple, and the benefits are huge. Unfortunately, THAT was the easy part. The way pages generate links needs to be looked at so that they no longer have the query strings in them. It is pointless having the site process search engine friendly urls if your site is not using them. And then the way the index.php file loads and shows what is needed once the page has the query string needs to be addressed.
At SEO Consult we understand that this can be difficult to reverse implement into a website, which is why we strongly advice clients who are redesigning or redeveloping their sites to implement search engine friendly urls at the beginning of the development cycle, as it is much much easier to implement from the start of development than it is at the end of development.








