Essential Steps for Changing Your WordPress Domain

wordpress domain changeupdate database sql301 redirect wordpressnotify search engineswordpress configuration
Published·Modified·

Recently, my blog underwent a domain change, which temporarily impacted the site's performance. Although we encountered a few minor issues during the process, they were resolved quickly. Here, I share the key points to watch out for to help your site recover smoothly.

1. Update Your Database Using SQL

Execute the following SQL statements individually. Replace http://www.zouxiuping.com with your old domain and http://www.xiaoz.me with your new domain.

UPDATE wp_options SET option_value = replace( option_value, 'http://www.zouxiuping.com', 'http://www.xiaoz.me' ) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace( post_content, 'http://www.zouxiuping.com', 'http://www.xiaoz.me' );
UPDATE wp_posts SET guid = replace( guid, 'http://www.zouxiuping.com', 'http://www.xiaoz.me' );

2. Check the wp_options Table

Run the following SQL query to verify if the siteurl and home fields reflect the new domain:

SELECT * FROM `wp_options` WHERE 1

If the fields show the new domain, the update was successful. If not, proceed to the next step.

3. Modify the Configuration File

This step is only necessary if the database update was unsuccessful. Add the following two lines to your wp-config.php file, replacing the domain with your new one:

define('WP_HOME','http://www.xiaoz.me');
define('WP_SITEURL','http://www.xiaoz.me');

4. Implement 301 Redirects

A 301 redirect is a crucial "automatic redirection" technique for permanently moving pages. It is the most viable method for URL redirection. Ensure all links from your old domain are permanently redirected to the new domain. For example, accessing http://www.zouxiuping.com/archives/4739 should automatically redirect to http://www.xiaoz.me/archives/4739.

5. Notify Search Engines

Baidu recommends waiting until a new site has been online for some time and has started to be indexed before using 301 redirects. Then, notify the search engine that the domain has changed. Note that Baidu may take some time to process this. Google, on the other hand, reacts faster and offers more comprehensive tools for webmasters.

改版规则 Figure 5-1: Change Rules

谷歌搜索 Figure 5-2: Google Search

6. Restore Friend Links

After changing your domain, your existing friend links will still point to the old domain. Inform your partners to update the links to the new domain. If they are unwilling to do so, use this period to find new friend links, which will help your site recover.

7. Update Analytics Codes

Your old analytics codes will not track the new website. Therefore, you need to obtain new analytics codes and add them. Popular website analytics tools include Baidu Statistics, CNZZ Data Statistics, and 51.la. Choose the one that best suits your needs.

These are the main points I have considered so far. Feel free to add more suggestions or correct any inaccuracies. ^_^