How to move a Wordpress from one domain to another? - developed.be

  • Published:October 9th, 2012
  • Category:Wordpress

To follow my example. This blog used to be on www.robinbrackez.be/uitgewerkt, and is now on www.developed.be

1) Backup/restore your database

If you want the website to be on a new databases (which is not always necessary), take a backup of the entire database (phpadmin > export > to file) and restore it in the new database (phpmyadmin > import > from file).

2) Edit wp-config.php

On a local copy of the website, edit the wp-config.php to edit the database settings. Edit the constants: DB_NAME, DB_USER, DB_PASSWORD. (in case there’s a new database, of course).

3) Move the php-files (or copy/paste)

In FTP, you can move the files from the one domain to the other. For safety reasons, copy your files first and delete them afterwards. Make sure you also copy the .htaccess file (it could be hidden).

Copy also your edited wp-config.php (from the previous step) in the new ftp-directory.

4) Edit some db-variables

In the new database, you must edit some records in table wp_options, because you might be unable to access the admin environment on the new domain at this time.

You can easily do this with phpmyadmin. Edit the records: “site_url” and “home” in the table “wp_options”. They should contain the new url without trailing slashes. (so: developed.be is ok but developed.be/ is not ok).

This way WordPress knows that your site is on a new url.

5) Edit .htaccess of the new website

If you worked on a subdomain but the new site is not a subdomain (like I did), you have to alter the .htaccess file. It should look like this:


RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

6) Edit Google-Analytics

In case you use Google-Analytics, create new profile on the site of Google and edit the tracking code in the admin area of WordPress (which should be accessible by now).

7) Check your new website on the new url. It should work

8 ) Redirect the old website to the new website

This is an important step one might forget: all visitors should be automatically forwarded to your new domain. Also: Google should be informed that your site has moved. If you simply leave the old website the way it was, you will confuse people and Google might see it as a duplicate site and degrade your new/old website. If you simply delete your old website without anything else, visitors will only see a server error and sigh.

We will solve this with .htaccess

Delete all the files in the old folder and create the following .htaccess file in the old folder:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.developed.be$
RewriteRule ^(.*)$ http://www.developed.be/$1 [R=301]

Change, of course, “developed.be” by your domain name.

This way people will be automatically forwarded when they access your site from the old url. The [R=301] means that your site is “permanently moved”. Google understands that rule and will change the old url’s to the new ones in the search results.

Test this url:

http://robinbrackez.be/uitgewerkt/2012/04/02/change-cron-settings-through-a-terminal/

You’ll see it will be forwarded to http://www.developed.be/2012/04/02/change-cron-settings-through-a-terminal.

It’s so user friendly, people won’t even notice.

 9) Maintenance

Remove your old database (if so), and the old files. (don’t delete the .htacess from the previous step).


Rss Comments

Comments

No comments yet.

Leave a comment