Make your website search engine friendly with SEO

Search Engine Optimization or SEO ,is the technique which makes search engine to conviniently crawl to your webpages.This invloves the translation of dynamic url to a search engine friendly url.

When we deal with a dynamic website ,it involves a server sided scripting language perform the server side actions. So we usually have the links of the type http://www.mohnish.co.in/index.php?catid=4&content=home

Now such types of links are not understood by the search engine when they crawl to search for webpages. the search engines can best understand the HTML format links,such as in the above case a much easy to understand link can be http://www.mohnish.co.in/index.php/4/home.html

Now converting this http://www.mohnish.co.in/index.php?catid=4&content=home to http://www.mohnish.co.in/index.php/4/home.html is the job of SEO technique.

The Process of making the dynamic url’s more friendly is done using two types of techniques.

1. Mod_Rewrite and 2.Forcetype

Mod_Rewrite:This is one of the techinique for making the dynamic url friendlier.We use a Readwrite rule to make the conversion. For this we need an htaccess file to be present in the websites root directory,This is used by the webserver to do the mapping from the dynamic url to the search engine friendly url.

for examplefor the above dynamic link viz

index.php?catid=4&content=home ,

The rewrite rule will be as below.

RewriteEngine On

RewriteRule ^(.*)/(.*)\.html /index.php?catid=$1&content=$2

This is a typical regular expression or regex. Now (.*)/(.*) is the first part of the regular expression and catid=$1&content=$2 is tht second part of regular expression. The expression compere and matches the values between (.*) to the second part of the regular expression. So the first (.*) becomes $1 and second (.*) becomes $2 in the translation process. So the dynamic url will automaticlly get converted to search engine friendly url.

So when the search engine encounters index.php?catid=4&content=home it will automatically do the translate it to index.php/4/home.html

To enable mod_rewrite on apache server navigate to c:\apache\conf\httpd.conf (we assume that apache is installed in c:\) ,

Open up httpd.conf in notepad and look for this line.

#LoadModule rewrite_module modules/mod_rewrite.so

Uncomment it so that it reads,

LoadModule rewrite_module modules/mod_rewrite.so

Next, search for AllowOverride None and change it to AllowOverride All.

NB: AllowOverride None appears 2 or 3 times in the configuration file(i.e in httpd.conf)

2.Second type of SEO technique is using the forcetype url translation.

This method is used in conjunction with PHP’s inbuilt ereg functions and str_replace function.To use first place tht following line in the htaccess file present in the root folder of your site.

ForceType application/x-httpd-php

Now create a file called “articles”:

$nav = $_SERVER[”REQUEST_URI”];
$script = $_SERVER[”SCRIPT_NAME”];
$nav = ereg_replace(”^$script”, “”, $nav);
$nav = str_replace(”.html”, “”, $nav);
$vars = explode(”/”, $nav);
$article = $vars[1];
$page = $vars[2];
require(”/index.php?act=articles&id=”.$article.”&page=”.$page);
?>

as we can see the url translation is done using the ereg function. This will replace the $script with a “” in $nav expression.explode exploes the $nav such that the parts of string with / are seperated and seperate array index values.

This example of forcetype SEO is obtained from http://www.seochat.com

April 21, 2008 Post Under Web Technology

Leave a Reply