This brief tutorial shows students and new users how to properly update WordPress permalinks.
WordPress permalinks are the permanent URLs of your blog pages, images, posts and other content. Each of these content has a permalink. This is the link to reference the content.
As you can see, WordPress permalinks are very important. If a WordPress content doesn’t not have the correct permalink in the database, it will be very difficult to browse and find that content.
Those also migrating to a new blog will have to adjust permalinks for each content. Without properly migrating those links, you blog will be a real trouble.
This lesson 53 tutorial shows new students and users how to correctly migrate or update WordPress permalinks.
Few of my other blogs have been migrated to HTTPS. For those who are contemplating moving to HTTPS will also need to adjust WordPress permalinks.
Step 1: Backup WordPress Database
Before adjusting or migrating WordPress permalinks, your first task will be to backup your database.
I always recommend users to backup their WordPress databases before making changes. In case something goes wrong, you’d be able to restore your database from the backup files.
If you’re using MySQL or MariaDB as your database server, run the commands below to backup your database.
sudo mysqldump -u root -p database_name > backupdatabase_name.sql
Step 2: Logon to MySQL Database server
Next, logon to MySQL database server by running the commands below.
mysql -u root -p
When prompted for your database root password, type it to continue.
Step 3: Update WordPress Post Content table
WordPress databases contain many tables that link to content on the server. These links are links to images, pages, post and other data.
To update WordPress permalinks contain in the post content table, run the SQL command statement below.
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.oldsite.com', 'https://www.newsite.com');
Step 4: Update WordPress Meta Table
After updating the post content table, run the commands below to update WordPress Meta table.
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'http://www.oldsite.com', 'https://www.newsite.com');
Step 5: Update WordPress Option value table
The final step is to update WordPress option value table. The table contains WordPress domain/site URL. Run the commands below to update that table.
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://www.oldsite.com', 'https://www.newsite.com');
When you’re done, logout of the database server and go and test the site. You should be able to hit the site via its new domain name.
So whether you’re migrating to a new domain name or turning on HTTPS, this blog post will get you correctly configured. Use the steps above to update your permalinks.
You may also like the post below: