In a continuation of the first lesson of Search Engine Optimization and Search Engine Friendly URLs, we’ll see here some technical details about Search Engine Friendly URLs how to implement, a comparaison between different techniques. Something that we’ll guide us to decide about which techniques to use in our website and how to use it.

URL rewriting
We’ll take the example of the previous article and we’ll see how to transform

http://domain.com/web/index.php?aid=4&cid=7 &title=article-title-here&cat=news&subcat=computers

into

http://domain.com/news/computers/article-title-here/4/7/

URL rewriting Requirements :

  1. Apache Server with mod_rewrite enabled.
  2. Access to create and edit .htaccess files on your server

Procedure :

We’ll write a .htaccess file and describe how the URL will be rewrited. This is our .htaccess file :

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)/(.*)/(.*)/([0-9]+)/([0-9]+)$ /index.php?aid=$4&cid=$5 &title=$3&cat=$1&subcat=$2

We’ve just written a regular expression that explode the URL in different parts that we’ll just call in the URL with $1,$2,$3 …etc.

Possible problems with URL rewriting
Its really a great technique for Search Engine Optimization but you could face some problems if you don’t write correctly the regular expression. Or your forget to change in your website relative links to absolute links specially for images, javascripts and style sheets.

Good points

  • Simple techniques don’t require lot of programming languages.
  • Very useful for website already running with non optimized URLs, moving the new URL rewriting will not broke the old links and will not need lot of changes inside the website itself.
  • We can play with URLs to create lot of great things, for example your url could finish with .html, a visitor will see them exactly like a static website.
  • And finally, we have fully search engine friendly website .

In the next article we’ll see more techniques for URL rewriting there is still four or five techniques for writing Search Engine Friendly URLs.