mod_rewrite is one of the most important seo tools you have. Its an extremely powerful accessory, and unfortunately can also be extremely complicated. These are some simple lines you can put in your .htaccess file for some simple rewriting.
First, add this at the very top of your file. It will add a www. to the begining of your domain if it is not already there.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[DOMAIN]\.com
Now we'll do something a little more useful - change a popular poorly written url to one thats more distinctive. Many sites use urls of the form [name].php?id=4. Were going to change that to */[name]/4/, where name is the name of the article or page. Add:
RewriteRule [name]/(.*)/ [name].php?id=$1
This basically says whenever the browser encounters [name]/(.*)/ where (.*) is anything, rewrite it to [name].php?id=$1 where $1 is equal to what (.*) was.
As a practical example, take a site about bees. Say you have a page called beetypes.php?id=4. The id corrosponds to the name of the bee, which happens to be honey. So in your .htaccess file you put the line
RewriteRule honey/(.*)/ beetypes.php?id=$1
Simple as that! Now you have a properly written url for seo purposes.
First, add this at the very top of your file. It will add a www. to the begining of your domain if it is not already there.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[DOMAIN]\.com
Now we'll do something a little more useful - change a popular poorly written url to one thats more distinctive. Many sites use urls of the form [name].php?id=4. Were going to change that to */[name]/4/, where name is the name of the article or page. Add:
RewriteRule [name]/(.*)/ [name].php?id=$1
This basically says whenever the browser encounters [name]/(.*)/ where (.*) is anything, rewrite it to [name].php?id=$1 where $1 is equal to what (.*) was.
As a practical example, take a site about bees. Say you have a page called beetypes.php?id=4. The id corrosponds to the name of the bee, which happens to be honey. So in your .htaccess file you put the line
RewriteRule honey/(.*)/ beetypes.php?id=$1
Simple as that! Now you have a properly written url for seo purposes.