===== Friendly Dynamic URLs =====
A Dynamic URL looks like this:
http://www.domain-name.com/index.php?id=1&code=123&product=15
This is not such a great idea for many reasons. First it is ugly, second it can be used to hacked your site or get others information if the site is not properly secured, and third, search engines don't like it. Google has a saying: id is NEVER indexed, 1 query string 90% change, 2 = 50%, more than 2 ... it's like shooting Craps!
So, how do we get around this? With .htaccess and Regular Expressions.
Append this into your .htaccess file after where you set up domain name redirects
==== .htaccess ====
# This code rewrites the url for every possible query result (for 1-3 at a time)
# I use this in my CMS
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?id=$1 [L]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?id=$1⊂=$2 [L]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)-]+)/([A-Za-z0-9-]+)/?$ index.php?id=$1&code=$2&product=$3 [L]
The code above looks for text after the domain name that matches index.php?id=[any value] and the $1 is a temporary variable that that [any value] is assigned to. The same goes for the other 2 lines as well.
So when you have a link on your site that goes to:
www.domain-name.com/1/123/15/
It takes the /1/123/15/ as /$1/$2/$3/ and behind the scenes where no one can see it is actually telling the script on index.php to GET these values "index.php?id=1&code=123&product=15". At the same time no one knows what programming language you wrote your site in so hacking is much more difficult.
Spiders automatically assume that www.domain-name.com/1/123/15/ is the same as www.domain-name.com/1/123/15/index.html, so it is not needed but if you want to add index.html to your url all you have to do is add it here:
RewriteRule ^([A-Za-z0-9-]+)/index.html?$ index.php?id=$1 [L]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/index.html?$ index.php?id=$1⊂=$2 [L]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)-]+)/([A-Za-z0-9-]+)/index.html?$ index.php?id=$1&code=$2&product=$3 [L]
The links on your site to your pages should look like this:
1) home < / a>
and NOT like this:
2) home < / a>
Remember 1 is doing what 2 does now.