Redirecting Dynamic URL to Static using .htaccess
I (finally) found some documentation today on how to redirect a dynamic URL to a static URL. For example changing www.example.com/page.php?article=22 to www.example.com/apples-and-oranges.php
This is your .htaccess file entry to do the above redirection, of course the RewriteEngine on command is only needed once before the first redirect... This will work for ONE variable pair
RewriteEngine on
RewriteCond %{QUERY_STRING} ^article=22$
RewriteRule ^page\.php$ http://www.example.com/apples-and-oranges.php? [R=301,L]
Now if you need to redirect a dynamic URL with more than one name/valu pair like this:
www.example.com/page.php?widget=cellphone22&color=red
You will need to use the following code:
RewriteEngine on
RewriteCond %{QUERY_STRING} [&]?widget=cellphone22[&]?
RewriteRule ^page\.php$ www.example.com/cellphone22.php? [R=301,L]
In this last example, &color=22 is ignored.
Resources for this post:
http://www.webmasterworld.com/apache/3365089.htm
http://www.seoverflow.com/blog/seo/setting-up-301-redirects-for-dynamic-urls/