Sometimes this happens, you’ve built the site and have to or want to change the domain it’s on. Or you did dev work on a different domain and now it’s time to go live.
The domain name is actually stored in numerous places in the database, as well as one line in wp-config.php. Every single one of these will need to be changed.
Before you do anything, backup. Go to phpMyAdmin, select your database, and choose Export. Save it to your computer. We’ll be making a copy of this and working on the copy. This way, if anything goes wrong, we still have our backup.
The database information – table structure, content, everything really – is stored in a file with the extension .sql. This can be read and edited in a simple text editor. If you’re a Windows user, try NotePad++ instead of the default Notepad.
Simple do a find and replace on olddomain.com to newdomain.com. Save your copy.
Method #1:
- on the live site, verify you have that backup, then drop all the tables in the database.
- import your edited sql file with the new domain name in it. (phpMyAdmin -> Import tab.)
- edit wp-config.php with the new domain name
- change the DNS records for the domain so the new one points to the right spot on your server if you haven’t done it already.
Method #2:
- create an entirely new database. Use an existing db user & password, or create a new one – your choice, as long as they have ALL privileges on this database.
- import your edited sql file with the new domain name in it. (phpMyAdmin -> Import tab.)
- edit wp-config.php with the new domain name AND the new database name, plus the new db user & pass if you did this.
- make sure your new domain is pointing to the right spot.
Do whatever you like with the old domain.


I put a copy of my live server onto a local machine and found all instances of the domain in the db and changed them. reading this made me go doh! search and replace on a single file would have been sooo much easier! :-z
Yeah, it was definitely a DOH! moment.
If you download the SQL backup file, you can use InfoRapid Search & Replace to quickly replace all instances. Will search through all the files within a folder, open them, do the replacement and then save and close. Can run through 1000 replacements in a minute or less!
It has saved me a ton of time in my Find and Replace needs! http://www.inforapid.de/html/searchreplace.htm
Hi,
Thanks a bunch for the quick tutorial!
I have a question: When you say “change the DNS records for the domain so the new one [...]“, where do I do this? In the .htaccess.., in the wp-config?
Thanks again.
This does not address the issue of poorly designed plugins that choose to save paths and urls in arrays in their own options. These arrays are generally serialized. Merely doing a search/replace will likely break the array unless the number of characters in the new name is exactly the same as the old name.
Otherwise, the serialized array wil have to be hand checked and have the character count adjusted accordingly.
Does these methods also apply to forcing www preference, that is changing domain name from domain.com to http://www.domain.com?
No, they do not. The www gets stripped elsewhere in the code.
Hi Andrea
Does your ebook cover how to setup WPMU so that you can set up multiple sites with the www. prefix on the domains?
If not do you know if it is possible?
Thanks
Richard
This process for me was quite smooth…moving from a dev server/domain to a new host/new domain. Sadly the new host does not support wildcard subdomains, so I’m forced to change the naming scheme to: domain.tld/blogname
Any suggestions on how to achieve this?
(also posed this question to the forum at mu.Wordpress.)
Best – H
Hi Andrea — awesome as usual!!
Quick question: I don’t see which line to change in the wp-config.php? Any help??
Am I uncommenting the redirect section and entering from the old domain to the new??
Thanks!
Oh.. I’m using 2.6… I don’t see where to enter or change “DOMAIN_CURRENT_SITE”.
Is it just an add?
Thanks, again!
Oops, nevermind. I saw that the new wp-config.php lines are added as part of the 2.7 upgrade. I did the upgrade as mentioned in another of Andrea’s posts and, voila… 2.71 living on a new domain.
Great post — thanks Andrea!
-Chris
There were one or 2 more added in 2.8 as well.
Help!!
I am very new to all this and followed the instructions to copy the sql file.
Can you explain what “drop all the tables means”?
Also when I went to import the new file with the domain changed, I have had an error come up:
#1062 – Duplicate entry ’1′ for key ‘PRIMARY’
drop means the same as delete. In phpmyadmin, there are links to drop the tables. You probably got the duplicate error because the tables weren’t dropped.
I’d like to do this however the new domain I’d like to use as my primary is one of the domains I have mapped with donncha’s Domain Mapping Plugin.
For example: http://domainilike.poorchoice.com is mapped to be http://domainilike.com. I’d like to make the mapped domain the primary. Is this going to cause problems?
I’ve been looking everywhere for this info and it’s great to find it so clearly expressed here.
I just have one question – if I use this technique, do I need to go and change the blog settings in the WPMU backend? Ie, under Site Admin, Blogs, where the urls, titles, etc are set?
This isn’t a techinique, it’s how you upgrade manually. There’s no need to change ANY urls or titles or anything.
Did you read pete’s post?
Hi Andrea,
I designed a web site as a subdomain of my MU.
mycustomer.mydomain.com
My customer want me to host the site on his url mycustomer.com (I have all codes, DNS are pointing to my server…) Basically we are going live!
When I edit mycustomer.mydomain.com from the MU admin panel, I can change the domain and/or site url and/or home… I tried every combinaison without success: I can access to mycustomer.com and see the blog, but I can’t acccess to the back-end… I always arrive to the login screen and when entering the correct admin/pwd the login page just reload without any message and prompt me to enter the login again.
Any recommendations? Should I wait WP3?
Thanks
Simon
Get the domain mapping plugin –
http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/
It makes things a whole lot easier.
Thanks for the original post Andrea, this worked a treat for me on changing the dev domain to the live one. So quick and easy.
Thanks
dkpw
I downloaded the SQL and did find replace for domains. Im using Domain Mapping plugin, but I only have wordpress configured for subdomains, not actually using the DM features yet. I have main.domain.net blog1.domain.net blog2.domain.net, etc. I can only login to the admin the main.domain.net for the main blog. I cant use the main admin account or others to get into the other blogs. I tried making the password the same in the database and changing passwords. I used to be able to login. The old setup was main: http://www.anotherdomain.net blog1.anotherdomain.net, blog2.anotherdomain.net, etc
The tutorial above wasn’t for domain mapping. It was for moving an entire WP netowrk to a different domain. The point of domain mapping is not changing the domain/url info in the database.
I’d like to say thanks for all your tutorials and help! I searched for your tutorial on changing the domain… I knew it would be easy and you sure did make it clear!