How to Fix WordPress Redirecting to Old Domain After Migration

How to Fix WordPress Redirecting to Old Domain After Migration [3 Effective Ways]

Last updated on

by


Are you struggling with WordPress redirecting to your old domain after a migration?

When you move your WordPress site to a new domain, there’s a chance that visitors might still be directed to the previous one.

Don’t worry! In this guide, we will walk you through three effective methods to resolve this issue and help make sure your site functions perfectly on its new domain.

Ready? Let’s get started!

Reasons Behind WordPress Redirecting to Old Domain After Migration Issue

When you move your WordPress site to a new domain, setting up proper redirection becomes essential. In this way, you can ensure that visitors land on the new domain while keeping your website’s traffic and search engine rankings.

However, incorrect redirection settings can cause users to be unexpectedly sent back to the old domain. There are two major factors that commonly lead to this issue:

  1. DNS Issues

Issues with the Domain Name System (DNS) can also cause redirection errors. If DNS records are outdated or if the DNS server isn’t responding, visitors may still be directed to your old domain instead of the new one.

  1. Mismatched Site URLs

One of the most frequent causes of redirection problems is inconsistent site URL and home URL values in the WordPress database. If these URLs do not point to your new domain, your website will continue redirecting to the old one.

3 Easy Ways to Fix the WordPress Redirecting to Old Domain After Migration Issue

Let’s now explore how to fix these issues and stop WordPress from redirecting to the old domain.

Solution #1: Verify and Update Your Website Address in WordPress

One of the simplest ways to stop WordPress from redirecting to the old domain is to check that the WordPress Address (URL) and Site Address (URL) match in your settings. If either field still points to the old domain, visitors will be redirected incorrectly after migration.

Here’s how you can fix it:

  1. Access WordPress General Settings: Log in to your WordPress admin dashboard and navigate to Settings » General.
  2. Update the Site Address (URL): In the Site Address (URL) field, enter your new domain. Ensure the WordPress Address (URL) field also reflects the new domain.
  1. Save Changes: After updating the URLs, click the Save Changes button at the bottom of the page.
  2. Test Your Website: Visit your new domain to confirm that the issue is resolved and the site no longer redirects to the old domain.

NOTE: If the URL fields appear greyed out and cannot be edited, proceed with one of the other methods outlined below to update your domain address.

Solution #2: Update the Website URL Directly in the WordPress Database

If WordPress continues to redirect to the old domain, you can resolve the issue by manually updating the website URLs in the database. This approach validates that the site URL and home URL are correctly set to the new domain.

You can do this by following these steps:

  1. Access Your Hosting Control Panel: Log in to the control panel of your WordPress hosting provider. For this guide, we’ll use Bluehost as an example, but the steps are similar for other hosts like SiteGround, Hostinger, and others.
  1. Open the phpMyAdmin Tool: Navigate to the Websites tab or equivalent in your hosting dashboard. Select your site and look for the phpMyAdmin option, typically under a section like Quick Links. Click on it to open the database management tool.
  1. Locate the wp_options Table: In phpMyAdmin, find your site’s database in the left-hand panel. Look for a table ending with _options (e.g., wp_options or staging_xyz_options). Click on it to open the table.
  1. Edit the siteurl and home Fields
    • Find the siteurl row and click Edit.
    • Replace the value in the option_value field with your new domain URL (e.g., https://www.newdomain.com) and click Go to save.
  • Repeat the same steps for the home row, ensuring it matches the new domain.
  1. Save and Test Your Site: After updating both fields, test your website by visiting the new domain to confirm the redirection issue is resolved.

Pro Tip: While the table names may vary slightly between hosting providers, the _options suffix remains consistent. Double-check to ensure you’re editing the correct rows.

By updating the database directly, you ensure the URLs are accurately configured, preventing redirection to the old domain.

Solution #3: Flush Your DNS Cache

If your website still redirects to the old domain after migration, the issue could be related to outdated DNS settings. When you change your domain, it may take up to 12 to 48 hours for the updates to propagate fully across the internet. During this time, some internet service providers (ISPs) might use outdated DNS records, causing users to be redirected to the old domain.

Flushing the DNS cache on your device forces it to retrieve updated information about your new domain and can help fix this problem. This way you can also fix the DNS Not Responding error as well.

Here’s how to flush the DNS cache based on your operating system:

On Windows:

  1. Open the Command Prompt by typing cmd into the search bar and selecting the application.
  2. In the Command Prompt window, type the following command:

ipconfig /flushdns

  1. Press Enter, and you’ll see a confirmation message that says, The DNS Resolver Cache has been successfully flushed.

On macOS:

  1. Open the Terminal by pressing F4, typing “Terminal” in the search bar, and selecting it.
  2. Use the appropriate command for your macOS version. For instance, on macOS Big Sur, type:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

  1. Press Enter and provide your administrator password when prompted.

Once the cache is cleared, your device will fetch the most up-to-date DNS records, ensuring users are directed to the new domain.

After flushing the DNS cache, visit your site to verify that the redirection issue has been resolved.

Additional Useful Method to Fix the WordPress Redirection to Old Domain After Migration Issue (Optional)

Manually configuring redirection to a new domain can often lead to errors, which may result in users being sent back to the old domain. To avoid this hassle, you can simplify the process by using a WordPress SEO plugin, such as All in One SEO (AIOSEO).

AIOSEO includes a robust Redirection Manager that allows you to redirect your entire site to a new domain seamlessly. This feature eliminates the risk of misconfiguration and guarantees that your users are directed to the correct domain without any interruptions.

This tool is specifically designed to handle redirection tasks efficiently, whether you’re migrating your website to a new domain or consolidating multiple sites into one. Its user-friendly interface makes it accessible even for non-technical users, allowing you to set up redirects in just a few clicks.

Using a reliable plugin like AIOSEO saves time and reduces the likelihood of mistakes, resulting in a smooth transition for your website visitors while maintaining your SEO rankings.

NOTE: Check out our guides about WordPress most common errors such as ERR_CONNECTION_RESET, error establishing a database connection, White Screen of Death in WordPress, etc. 

Conclusion

You can resolve the WordPress redirecting to old domain after migration issue by taking the right steps. Update your WordPress and site URLs, modify the database entries, or flush the DNS cache to let users access your new domain without interruptions. These actions will keep your site running smoothly and maintain its SEO performance.

Key Takeaways:

  • Check and update the WordPress Address (URL) and Site Address (URL) in your settings.
  • Update the siteurl and home fields directly in the database when necessary.
  • Flush your DNS cache to force your device to recognize the new domain.

These solutions, combined with an SEO plugin like AIOSEO, allow for a smooth migration and a great user experience.

Have questions or tips to add? Share them in the comments below!

Frequently Asked Questions

How to redirect old domain to new domain in WordPress?

To redirect your old domain to a new domain in WordPress, you can use a redirection plugin like All in One SEO (AIOSEO). Follow these steps:

  1. Install and activate the plugin in your WordPress dashboard.
  2. Navigate to the Redirection Manager and set up a 301 redirect for your old domain to point to the new one.
  3. Save your settings and test the redirection to ensure it works.
  4. Alternatively, you can add a redirect rule to your .htaccess file if you prefer manual changes.

Why does my WordPress URL keep redirecting?

Your WordPress URL might redirect due to:

  • Mismatched siteurl and home values in the WordPress database.
  • Outdated or corrupted DNS cache causing your device to access old records.
  • Plugins or server configurations that automatically enforce redirection rules.
    To fix this, verify your WordPress URL settings, flush your DNS cache, and review active plugins or server rules for unwanted redirects.

How do I stop WordPress from redirecting?

To stop WordPress from redirecting incorrectly, follow these steps:

  1. Check and update your WordPress Address (URL) and Site Address (URL) in the WordPress settings.
  2. Verify and update the siteurl and home values in the database using phpMyAdmin.
  3. Deactivate plugins or themes that might be enforcing unwanted redirects.
  4. Test your .htaccess file for redirection rules and remove any unnecessary ones.

How to fix redirects in WordPress?

You can fix problematic redirects in WordPress by:

  • Identifying the issue: Check for plugin conflicts, incorrect database entries, or server misconfigurations.
  • Updating URLs: Ensure the WordPress and Site Addresses match your current domain.
  • Using tools: Install a redirection plugin like AIOSEO to manage and resolve redirection issues.
  • Clearing caches: Flush your browser, DNS, and plugin caches to ensure changes take effect.

By following these methods, you can eliminate unwanted redirects and ensure your WordPress site functions as expected.