OK, hands down I'll admit I've never done this before but with the majority of our sites rendering dynamic content I figured it's time I learn how to prettify URL's !

Essentially I understand the logic, the trick is executing it.

2 parts. (Sorry non LAMP folks!)

1. Generate an SEO crafted URL using PHP. This is the 'easy' part. This is a nifty little function I scraped from the internet for cleaning out crud from a URL.

function friendlyURL($string){
	$string = preg_replace("`\[.*\]`U","",$string);
	$string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string);
	$string = htmlentities($string, ENT_COMPAT, 'utf-8');
	$string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string );
	$string = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $string);
	return strtolower(trim($string, '-'));

2. Second, using Apache. Enable mod_rewrite and in an .htaccess file add RewriteEngine on. With the Rewrite Engine on you can now start writing some rules. For example RewriteRule ^article/([0-9]+)/([0-9]+)/(.*?).html$ /article.php?articleid=$1&categoryid=$2. This states what crafted URL to look out for, and the second part states where it should resolve to. The dollar($) sign tells mod_rewrite that this is the end of the pattern to look for, the proceeding syntax tells it where to go. mod_rewrite easily understand RegEx patterns so get revising !

Over the next few days I'm going to experiment putting this into practice and will be documenting what I learn. I constantly use my own site for personal reference.

Links & Further Reading (some useful articles I've found):