Moving a Drupal site to a new domain or subdomain
(Note: If you are trying to move a Drupal site to a new host, see the comment.)
As I've written before, one of the great things about Drupal is that it simplifies the management of many domains from one codebase. Surprisingly, Drupal also makes it incredibly easy to move entire websites from one domain (www.example.com) to another (www.anotherexample.com) or from a subdomain (subdomain.example.com) to a main domain (www.example.com). Confused? If you are, you might want to consider getting out of the webmastering business.
What I'm talking about is this: If I wanted to move this entire site from chucklinart.com to funnytechguru.com, I could do it in less than five minutes. Here is how:
- Create a "funnytechguru.com" folder in my "sites" directory with three folders under it -- "files," "themes," and "modules."
- Activate (assign) the new domain.
- Delete the folder that is created in that process (usually "funnytechguru").
- Create a symbolic link in the root directory of my Drupal installation from root --> funnytechguru.
- Copy the files from the "chucklinart.com" folder in my "sites" directory to my newly created "funnytechguru.com" folder.
- Navigate to funnytechguru.com just to make sure everything's working properly (it will).
- Open myself a bottle of Perrier, kick back and watch dancing girls do belly flops in my Olympic-sized pool full of money. (You can be flexible with this step. If you don't have a pool full of money, just ask the dancing girls to dance in your Great Room. They will be happy to oblige because you are so awesome. Female webmasters and gay webmasters can skip this step or do something else while they sip the mineral water. Heck, the mineral water itself can be replaced with beer or champagne. The point is that you have a ton of flexibility at this point.)
As I enjoyed the show, I would probably take care of a few other little odds and ends like deleting the old site from chucklinart.com and replacing it with a new site devoted to my absolute obsession with the yellow bellied warbler. Of course I would want to set up a 301 redirect in my .htaccess file just to let the search engines know that this content is still mine and I'm not a scumbag scraper to be banished to the high plains of Cyber Mongolia (no offense intended to my many Mongolian readers).
By the way, the code to do the 301 redirect looks like this:
RewriteCond %{HTTP_HOST} ^chucklinart\.com$ [NC]
RewriteRule ^(.*)$ http://www.funnytechguru.com/$1 [L,R=301]
(You'll know where to put it in the .htaccess file if you're using Drupal, not that it matters.)
Actually, come to think of it, I would probably develop the new yellow bellied warbler site locally, not on the server, because I would want to redirect everything smoothly and give the search engines some time to take the hint. Then I would remove the previous two lines of code from .htaccess and upload the new site. You get what I'm saying, right? If not, you might want to consider a career move because webmastering might not be for you. Sure, the perks are nice -- the dancing girls and swimming pools full of money and all that -- but it's not for everybody.
Anyway, Drupal continues to amaze me. I've moved a few sites in my time, and it's never been this easy.



Moving a Drupal domain to a new host
Some people seem to be searching for the answer to this. It's really simple.
Preparation: Make sure your new host uses the same version of PHP as the old host. Most are using PHP 5.x now so it's 99 percent sure that you'll be OK here -- but make sure. If your new server uses PHP 5 but your old server was on PHP 4, your migration will be more involved than the below steps.
Step 1: Export your database and save. I usually export as both .csv and .xls just to be sure.
Step 2: Copy the entire directory structure of your Drupal site -- including all files, modules, and themes -- to your local machine. Make sure to get php.ini and .htaccess or you could be in a world of hurt!
Step 3: Import the database to the new host. (Make sure to set the database name, username and password to the same values as on the old host! DB username and password can both be found in your settings.php file if you've forgotten.)
Step 3: Upload the entire directory structure -- including all files, themes, and modules -- to the new host
Step 4: Change the DNS information to that of the new host.
Step 5: Presto. You're done!
Step 6: Be glad you're not using Wordpress, Joomla, or some other inferior CMS.
Post new comment