Move a website or directory

Moving a directory, subdomain, or entire website using .htaccess.

Let’s say you are moving an entire website to a new domain like example.com to www.website-whisperer.com.  Or you are moving a directory to a subdomain such as website-whisperer.com/awesome to awesome.website-whisperer.com.

Lets further say that there are people who may have bookmarked your pages or you are moving a site that has a search engine like WordPress.

For example:
http://website-whisperer.com/blog/?page_id=285
is moving to
http://blog.website-whisperer.com/?page_id=285

Now, you don’t want to have to change all the links that point to your old pages, or in the case of dynamic data, you can’t change all that stuff.

Here’s the answer:
Use the .htaccess file.  Either create a new .htaccess file or overwrite the old one. This file should be in the directory to be moved and should be the only file there.

RewriteEngine on
RewriteRule ^(.*)$ http://new_subdomain.website-whisperer.com/$1 [R=301,L]

Pretty easy eh?