loader

How to Change Domain in WordPress Website Using phpMyAdmin: Fixing Redirect Issues

Table of Contents

Changing the domain name of your WordPress site can be a critical step in rebranding or expanding your online presence. This guide will help you through the process using phpMyAdmin, ensuring you handle common issues effectively.

  1. Introduction
  2. Prerequisites
  3. Step 1: Backup Your Database and Files
  4. Step 2: Access phpMyAdmin
  5. Step 3: Select Your WordPress Database
  6. Step 4: Locate and Edit the wp_options Table
  7. Step 5: Update the Site URL and Home URL
  8. Step 6: Update the wp_posts Table (Optional)
  9. Step 7: Update the .htaccess File
  10. Step 8: Clear Cache
  11. Step 9: Test Your Site
  12. Step 10: Troubleshooting Common Issues
  13. Conclusion

Introduction

Changing your WordPress site’s domain involves updating the database and ensuring all redirects are properly configured to maintain your site’s functionality and SEO ranking. This guide provides a step-by-step approach to make this process seamless.

Prerequisites

  • Access to your web hosting control panel (e.g., cPanel, Plesk).
  • Access to phpMyAdmin through your hosting control panel.
  • Basic understanding of navigating through phpMyAdmin and your file manager.

Step 1: Backup Your Database and Files

Before making any changes, always back up your WordPress site. This includes both the files and the database. In case something goes wrong, you can restore your site from the backup.

Backup WordPress Files:

  1. Log in to your hosting control panel.
  2. Navigate to File Manager.
  3. Select your WordPress directory (usually public_html).
  4. Compress the directory into a ZIP file.
  5. Download the ZIP file to your local machine.

Backup WordPress Database:

  1. In your hosting control panel, open phpMyAdmin.
  2. Select your WordPress database.
  3. Click on the Export tab.
  4. Choose the Quick export method and the SQL format.
  5. Click Go to download the database backup.

Step 2: Access phpMyAdmin

  1. Log in to your web hosting control panel (e.g., cPanel).
  2. Locate and click on the phpMyAdmin icon under the Databases section.

Step 3: Select Your WordPress Database

  1. In phpMyAdmin, find your WordPress database from the list on the left and click on it.
  2. This will expand and show all the tables in your WordPress database.

Step 4: Locate and Edit the wp_options Table

  1. In the list of tables, find and click on the wp_options table. Note that the table prefix (wp_) may be different if you changed it during WordPress installation.
  2. Once in the wp_options table, you’ll see a list of fields.

Step 5: Update the Site URL and Home URL

  1. Look for the fields named siteurl and home. These fields usually appear on the first page. If you don’t see them, use the search function.
  2. To edit the siteurl and home values, click on the Edit link next to each of these fields.
  3. In the option_value field for both siteurl and home, update the URL to your new domain. Make sure to include the full URL (e.g., https://newdomain.com).

Example SQL Query: If you prefer to use an SQL query, you can run the following commands in the SQL tab of phpMyAdmin:

UPDATE wp_options SET option_value = 'https://newdomain.com' WHERE option_name = 'siteurl';
UPDATE wp_options SET option_value = 'https://newdomain.com' WHERE option_name = 'home';

Step 6: Update the wp_posts Table (Optional)

Sometimes, internal links in your posts and pages may still point to the old domain. To fix this, you need to update the URLs in the wp_posts table.

Example SQL Query:

UPDATE wp_posts SET guid = REPLACE(guid, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://olddomain.com', 'http://newdomain.com');

Step 7: Update the .htaccess File

  1. In your hosting control panel, open the File Manager.
  2. Navigate to the root directory of your WordPress installation (usually public_html).
  3. Find and edit the .htaccess file to ensure any old URLs are redirected to the new domain.

Example .htaccess Rules:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]

Step 8: Clear Cache

  1. Clear your browser cache.
  2. Clear any caching plugins on your WordPress site.
  3. Clear the server cache if your hosting provider offers caching services.

Step 9: Test Your Site

Visit your new domain and navigate through your site to ensure everything is working correctly. Check for any broken links or missing images and update them if necessary.

Step 10: Troubleshooting Common Issues

Issue 1: Site Not Loading Properly

  • Symptom: The site is not loading correctly or showing a blank page.
  • Solution: Check the siteurl and home values in the wp_options table. Make sure they are correct. Clear your browser cache and site cache.

Issue 2: Redirect Loops

  • Symptom: The site keeps redirecting back to the old domain or showing too many redirects.
  • Solution: Ensure the .htaccess file has the correct redirect rules. Clear your browser cache and server cache. Check the siteurl and home values.

Issue 3: Mixed Content Warnings

  • Symptom: The site loads, but with warnings about mixed content (HTTP and HTTPS).
  • Solution: Update all internal links to use HTTPS. This includes updating URLs in the wp_posts table as shown in the optional step above.

Issue 4: Broken Links and Missing Images

  • Symptom: Internal links and images are broken or missing.
  • Solution: Update the URLs in the wp_posts table to reflect the new domain. Use a plugin like Better Search Replace to update URLs throughout your database.

Issue 5: Login Issues

  • Symptom: Unable to log in to the WordPress admin panel.
  • Solution: Check the wp_options table for correct siteurl and home values. Clear your browser cache and cookies. Reset the password if necessary.

Conclusion

Changing the domain name of your WordPress site using phpMyAdmin involves several steps, but by carefully following this guide, you can ensure a smooth transition. Always remember to back up your site before making changes, and be prepared to troubleshoot common issues that may arise.

By understanding each step and knowing how to address potential problems, you can confidently update your WordPress site’s domain and maintain its functionality and SEO ranking. If you encounter any difficulties, refer back to this guide to ensure no detail is overlooked.

Leave a Reply

Your email address will not be published. Required fields are marked *