SEO Friendly Url
First of all what is a friendly URL? Simple put it is a url that is easy for the user to remember. Think what is easier to remember www.blake.com/resume or www.blake.com/?filetoget=resume.doc. If its easier to remember then its easier to link too. Google and other search engines know this I believe that is the primary reason they put weight to it, not because the spider cares, but because they knows its easier on the user.
There are actually a couple of different ways to create friendly URLS on your site. A lot of it depends on if its a old existing site you are trying to “work” friendly urls back into the code base or a new site. If its a new site much more than likely this is a moot point since friendly URLS will more than likely already be incorporated, but you will be surprised how many sites out there still use something along the lines of www.test.com/?productid=29.
Different way to create friendly urls
Lets say you have a new site www.test.com and a directory called “foo” sitting in the root the URL becomes “www.test.com/foo/”. This is called a static structure but the URL iswhat I would call friendly to the user. You could conceivable have a 1000 directories on your site each with an index file and a nice pretty URL. I certainly wouldn’t recommend this in the long run it would a lot more hassle than its worth.
The other option and probably most popular option is to have a site that is database driven and uses PHP or another scripting language to create dynamic URLS. “Way back when” the standard for this was something along the lines “www.test.com/?productid=10&categoryid=3″ this would give you the product ‘number 10 in category 3 from the database. This isn’t what we are looking for. Ideally since its database driven you can create the URLS to “appear friendly” without the directory structure. Lets take the example we used earlier “www.test.com/foo/”. To create this structure you would simply need to associate “foo” with the page in the database. When the URL comes in break off the root URL and process what is leftover with whatever logic the site dictates.
PHP example of Friendly SEO urls
The code below is assuming a incoming URL like www.blake.com/test/?q=idontcatre.It gets the request URL which would be “test/q=idontcare” and chops off the “/q=idontcare”. Then uses “test’ to look up the appropriate page in the database and display.
$arr = explode(“?”,$_SERVER['REQUEST_URI']);
$request = $arr[0]; //chop off query parameter
$request = trim($request,’/');
$sql = “select page from categories where PageUrl = ‘” . $url . “‘”;
$qid = $DB->query($sql);
$row= $DB->fetchRow($qid);
echo $row['page'];
Any thoughts? What did I miss? I did make a mistake once so it is possible
Any questions ask and I shall answer
