Creating search engine friendly URLs using the .htaccess file.
The power of Apache!
Date Created:Friday August 01st, 2008 11:09 AM
Date Modified:Friday August 01st, 2008 12:52 PM
You can use regular expressions to change a url such as
http://www.yourdomain.com/?this=3&that=4
to something that search engines like google would rather index, like:
http://www.yourdomain.com/this/3/that/4
Simply turn the Rewrite engine on, as displayed in the example .htaccess file below. The [R] means that it redirects and the user is aware. That is used in the first line of each URL change to ensure that the '/' is on the end of the URL. The rest is just regular expressions.
RewriteEngine on
RewriteBase /
RewriteRule ^errors/([a-z_]+)$ errors/$1/ [R]
RewriteRule ^errors/([a-z_]+)/$ ?errors=$1
RewriteRule ^user/([0-9]+)$ user/$1/ [R]
RewriteRule ^user/([0-9]+)/$ ?user=$1
