My blog used to be located at blog.petewood.us.  I just moved it to www.acedanger.com.  I had some decent search engine rankings on a few keywords and I didn’t want to lose them.  I knew there was a way to rewrite the URL so that if someone clicked on a link to one of my old pages, it would redirect them to the same page on the new domain.  For example, if someone clicked on a link to blog.petewood.us/2006/07/11/vacation/, I wanted them to be redirected to www.acedanger.com/2006/07/11/vacation/.  I have never written any scripts to rewrite URLs before so I turned to google for all the answers.  I found some info from several pages and came up with this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.petewood\.us
RewriteRule ^(.*)$ http://www.acedanger.com/$1 [r]

What this does is exactly what I have described in my example above.  I hope this helps someone out.  To test what I wrote, just click on the blog.petewood.us link above and it should take you to the acedanger.com page.

Filed under: Tech NewsWebsite

Like this post? Subscribe to my RSS feed and get loads more!