WordPress Migration + Domain Change
This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文
Step 1: Back up the original wordpress root directory. For example, create an archive on test.czl.net, copy it to czl.net, and extract it.
Step 2: Back up the database using phpmyadmin or your hosting provider's backup tool. For example, name the database backup test_czl_net.sql
Step 3: Import the database backup into the new database (create the database before importing).
Step 4: Modify the database tables:
1.In the wp_options table, find the row whose option_name is siteurl and change its value to the new blog URL, such as https://www.czl.net
2.In the wp_options table, find the row whose option_name is home and change its value to the new blog URL, such as https://www.czl.net
Step 5: Modify the wordpress configuration file wp-config.php
The four main fields to change are DB_NAME,DB_USER,DB_PASS,DB_HOST
Update these four fields to match the new database configuration
Step 6: Set up a permanent redirect from the old domain to the new domain
For example, edit the .htaccess file in the root directory of the old hosting account and add
redirect 301 / https://www.czl.net
Note: Also, change the default upload path in the wordpress admin panel to the new path. Otherwise, you may be unable to upload images for your posts.
Some online guides say you need to change the upload path, but I couldn't find that setting, even after checking the database. I'm not sure whether it was removed in a later update.
Another note: If some images do not appear after migration, their URLs in the posts must still point to the old location. Log in to phpmyadmin and run the following sql:
UPDATE `wp_posts` SET `post_content` = replace (`post_content`,’test_czl_net/test_czl_net/wp-content/uploads’,'www_czl_net/wp-content/uploads’)
This replaces all old image URLs in the posts with the new URLs.
Last updated 2024-01-14
Comments 0