URL Rewriting with .htaccess

A quick guide to URL Rewriting

#Start URL Rewriting

Options +FollowSymLinks
RewriteEngine on

#This will rewrite all non-www urls with www
# ie http://example.com will be rewritten as http://www.example.com

RewriteCond %{HTTP_HOST} ^example.com

RewriteRule (.*) http://www.example.com/$1 [R=301,L]

#This statement ReDirects all urls with trailing / to urls without trailing slash

RewriteRule ^([_a-zA-Z0-9-]+)/+$ /$1 [R]

#This statement ReWrites all urls of the form http://www.example.com/?blog.php?ID=xx as http://www.example.com/xx

RewriteRule ^([_a-zA-Z0-9-]+)+$ /blog.php?ID=$1

#END URL Rewriting

This entry was posted in SEO, URL Rewriting and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *