Warning: You will need to deal with phpMyAdmin and SQL queries to finish the steps. If you don’t know how to handle that do not perform these steps. First check the steps and see whether you can complete them.
Today I created a hosting account on hostgator.com. This is the first time I am using hostgator so I will see how that turns out later.
Anyways, I deployed my website on hostgator for test purposes to see if it was working on a live deployment. Everthing was good and site was working beautifully. Then I decided I would change the domain name I use for this site. Why did I not use the second domain name while configuring the wordpress hosting? I don’t know 🙂
So, here is how you can change the domain name you use for a wordpress site on hostgator using cpanel.
Note1: This will change the domain name for your root site, not add a new domain with a different content. This is not adding a second domain! Don’t get confused. Below is a step-by-step guide to change domain name of your WordPress site:
1- Login to your hostgator cpanel
2- Click “Addon Domains” under “Domains” section
3- Addon Domains page will load
4- Enter the new domain name that you want to use into the “New Domain Name” field
5- Change the auto generated ftp username if you like
6- Leave “Document Root” empty (we are setting a new domain for the existing site’s root)
7- Type in a strong password
8- Click “Add Domain” button
9- Wait for a couple of minutes
Now you need to change the site name in your WP installation.
1- Launch phpMyadmin in your cpanel
2- Click the “xxx_options” (wp_options by default) table on the left pane
3- Change the values of “siteurl” and “home” to your new domain name (should be on first and second pages respectively)
4- Click the “SQL” button on the top and enter the query below
UPDATE xxx_options SET option_name = ‘http://www.NEWdomain.com’ WHERE option_name = ‘http://www.OLDdomain.com’
5- Run the query
6- Final step is to replace all the remaining olddomain.com with newdomain.com. You will use this plugin to achieve that.
Now the content of your website will display when you visit your new domain name.
Note2: I assume you have configured the DNS servers of your domain on your registrar to your hostgator nameservers (sent by email when you create your hostgator account for the first time).
Hope this helps someone.