Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'd like to move a WP installation from a subdomain to its own without losing the PageRank achieved by that subdomain.

What are the best steps in order to do this properly? Especially how do I set the redirects properly?

share|improve this question
add comment

1 Answer 1

Follow these instructions on moving WordPress, but use the root domain for references to your old subdomain instead of the /blog/ directory (I've made this change for you in the steps below):

  1. Create a robots.txt file in the root directory of the new domain with the following contents:

    User-agent: *  
    Disallow: /
    
  2. Copy the database and files to the new domain.

  3. Edit wp-config.php to have the new database settings, and add the following lines, replacing example.com with the new domain:

    define('WP_SITEURL', 'http://www.example.com');  
    define('WP_HOME', 'http://www.example.com');
    
  4. Now set up your blog install with the same settings as on the old domain. (If you have a caching plugin installed, delete your cache files.)

  5. Install the Search and Replace plugin, and do a search and replace for your old URL to change it to your new URL.
  6. Once you're done moving WordPress and you've checked everything works twice, remove the robots.txt file.
  7. On your old blog, add the following line to the top of your Apache .htaccess or vhost-config:

    Redirect 301 / http://www.newdomain.com/
    
  8. Remove the old blog code and database.
  9. Change your FeedBurner account, if you have one, to pick up the correct feed.

To keep your PageRank, the crucial step is step 7, which redirects requests for your old blog pages to the new site.

Also see Moving WordPress and Changing The Site URL.

share|improve this answer
    
Thanks Nick, Great Job! The guys at my hosting service told me that all I needed to do is to copy the files to the new domain, I thought that it couldn't be that easy... –  dianibeach Aug 17 '11 at 7:38
    
You're welcome! Yes, it's a little more complex than moving some files across. Setting up and testing that redirect in step 7 is really important. You'll lose PageRank and traffic if you forget that step. (Also, don't delete the old folder that used to contain the subdomain by accident after you've set up the redirect. You can delete its contents once the redirect is working, but you need to leave the actual folder and the .htaccess file inside it alone.) Finally, it's worth using Google's change of address tool. –  Nick Aug 17 '11 at 7:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.