Next technique for Search Engine Optimization and Search engine friendly URLs is the technique of PATH_INFO. This technique is very simple to implement but require some programming. We’ll see later the difference between the previous technique and this one, how to implement it, good points … etc.


Implementation

The implementation of this technique is very simple as I’ve already said and require some server side programming. The idea is to convert URLs from :

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

into

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

You notice the difference compared to the previous technique is that URLs here still display the filename index.php and will consider the rest as parameters.

Now if we go to PHP and create just a simple script index.php with this code :

print_r($GLOBALS['HTTP_SERVER_VARS']['PATH_INFO']);

and request the URI

http://localhost/index.php/news/computers/article-title-here/4/7/

You’ll see the result below

/news/computers/article-title-here/4/7/

Now you’ll just need to implement this technique to explode different values in URI and create the suitable variables for your applications for example :

$PATH_INFO = $GLOBALS['HTTP_SERVER_VARS']['PATH_INFO'];
$info = explode('/',$PATH_INFO);
$cat = $info[0];
$subcat = $info[1];
$title = $info[2];
$aid = $info[3];
$cid = $info[4];

And we got exactly the same result than when we write

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

Its possible to hide the extension .php if you want and if your server configuration support it by adding in .htaccess :

ForceType application/x-httpd-php


Then create a copy of index.php and name it “index” only !. Now you can call directly http://localhost/index/news/computers/ …

Good points

Simple technique, easy to implement and allow you to create search engine friendly urls. An excellent solution for Search engine optimization, we can create any type of variables in URL and then manage it from code.

Bad points

The only bad point that I see in this technique is that it require to add some programming in the website’s code. It will be hard to implement if your website is already running, the URL rewriting will be a better choice in that case.

There is still some more techniques to discuss for search engine friendly URLs, and also some very important issues that we’ll see about search engine optimization, and how to take the maximum of advantages from these techniques.