If you’ve recently migrated your WordPress website to a new domain and find yourself stuck with a frustrating issue where it keeps redirecting to the old domain, don’t worry – you’re not alone! This common problem can be a real headache, but fear not, we’re here to help you resolve it. In this guide, we’ll provide simple, step-by-step instructions to fix the WordPress redirect issue and ensure your website operates smoothly on its new domain.
Understand the WordPress Redirect Problem
Before we dive into the solutions, let’s understand why WordPress might be redirecting to your old domain. Knowing the root cause will help us tackle the issue effectively.
1.1 What Causes the Redirect Problem?
When you migrate a WordPress website, your database and settings still contain references to the old domain. WordPress uses these references to generate links and URLs, causing the redirect problem. To resolve it, we need to update these references to the new domain.
1.2 Why Is This a Concern?
The old domain redirects can negatively impact your website’s user experience and search engine ranking. Visitors might become confused, and search engines may consider it a duplicate content issue. Resolving this issue promptly is crucial for your website’s success.
Backup Your Website
Before making any changes, it’s vital to create a backup of your website. This ensures that if anything goes wrong during the fix, you can always revert to the previous state.
2.1 How to Backup Your Website
- Install a reliable backup plugin like UpdraftPlus or BackupBuddy.
- Follow the plugin’s instructions to create a complete backup of your website.
- Store the backup files in a secure location, preferably off-site.
Update WordPress Settings
Now that you have a backup, let’s start by updating your WordPress settings to reflect the new domain.
3.1 Change WordPress Address and Site Address
- Log in to your WordPress dashboard.
- Go to Settings > General.
- In the “WordPress Address (URL)” and “Site Address (URL)” fields, replace the old domain with the new one.
- Click “Save Changes.”
3.2 Update Permalinks
- Still in the WordPress dashboard, go to Settings > Permalinks.
- Ensure your desired permalink structure is selected.
- Click “Save Changes.”
These steps will update your WordPress settings to use the new domain, but there may be other references to the old domain in your content and database.
Search and Replace in Database
To fix the WordPress redirect issue completely, you’ll need to search for and replace instances of the old domain within your website’s database.
4.1 Use a Plugin for Search and Replace
- Install and activate a search and replace plugin like “Better Search Replace” or “Velvet Blues Update URLs.”
- Go to the plugin’s settings page.
- In the “Search for” field, enter your old domain (e.g., oldwebsite.com).
- In the “Replace with” field, enter your new domain (e.g., newwebsite.com).
- Select the tables you want to search and replace in, usually all of them.
- Check the box to create a backup of the database before making changes (for safety).
- Click “Run Search/Replace.”
The plugin will scan your database and replace all instances of the old domain with the new one. This can take a few minutes, depending on the size of your website.
4.2 Clear Cache
After the search and replace process is complete, clear your website’s cache to ensure that the changes take effect immediately. Many caching plugins have a “Clear Cache” button in their settings.
Check Your Theme and Plugins
Sometimes, the redirect issue can be caused by theme or plugin settings that still reference the old domain.
5.1 Theme Settings
- Go to your WordPress dashboard.
- Navigate to Appearance > Themes.
- Activate the theme you’re using.
- Look for any theme-specific settings that mention the old domain and update them to the new domain.
5.2 Plugin Settings
- Go to your WordPress dashboard.
- Navigate to Plugins.
- For each active plugin, check their settings for any references to the old domain.
- Update any relevant settings with the new domain.
Check .htaccess File
The .htaccess file in your WordPress root directory can also affect website redirects. Ensure it’s configured correctly.
6.1 Access .htaccess File
- Use an FTP client or your hosting control panel’s file manager to access your website’s root directory.
- Look for the .htaccess file.
6.2 Edit .htaccess File
- Download a copy of the .htaccess file as a backup.
- Open the .htaccess file using a text editor.
- Check for any lines that mention the old domain and replace them with the new domain.
- Save the file and upload it back to your website’s root directory, overwriting the existing file if necessary.
Test Your Website
Now that you’ve made all the necessary changes, it’s time to test your website to ensure the redirect issue is resolved.
7.1 Clear Browser Cache
Before testing, clear your browser’s cache to ensure you’re not seeing cached redirects.
7.2 Test the Homepage
- Open a new browser window.
- Enter your new domain (e.g., newwebsite.com) and press Enter.
- Verify that your website loads correctly without any redirects to the old domain.
7.3 Test Internal Links
Click on various internal links within your website to ensure they also navigate to the new domain without any issues.
7.4 Test External Links
If your website has external links, click on them to make sure they open in new tabs or windows and don’t redirect to the old domain.
7.5 Check for Mixed Content
In your browser’s address bar, check for a padlock icon or the word “Secure” to ensure your SSL certificate is working correctly. If you see any mixed content warnings (HTTP elements on an HTTPS page), address them promptly.
Redirects and SEO
To maintain your website’s SEO, you should set up proper redirects from the old domain to the new one.
8.1 Redirect Old Domain
- Access your hosting control panel or use an FTP client to edit the .htaccess file.
- Add the following code at the top, replacing “oldwebsite.com” with your actual old domain and “newwebsite.com” with your new domain:
apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldwebsite\.com$ [NC]
RewriteRule ^(.*)$ http://newwebsite.com/$1 [R=301,L]
</IfModule>
- Save the file.
8.2 Submit Sitemaps to Search Engines
Resubmit your sitemap to search engines like Google and Bing to notify them of the domain change. Use Google Search Console and Bing Webmaster Tools for this purpose.
8.3 Update External Links
If you have control over external links to your website (e.g., social media profiles or directory listings), update them to point to your new domain.
Monitor Your Website
After fixing the WordPress redirect issue, it’s essential to monitor your website for any potential problems.
9.1 Regularly Check for Redirects
Periodically check your website to ensure it’s not reverting to the old domain.
9.2 Monitor SEO Performance
Keep an eye on your website’s SEO performance, including rankings, traffic, and indexation. Any significant drop in SEO metrics could indicate issues related to the domain migration.
9.3 Stay Updated
Regularly update your WordPress core, themes, and plugins to ensure they remain compatible with your new domain.
Conclusion:
Migrating your WordPress website to a new domain is a significant step in your online journey, and it’s essential to ensure a smooth transition. The redirect issue can be a common roadblock, but with the steps outlined in this guide, you can fix it and enjoy a seamlessly functioning website on your new domain.
Remember, patience and thoroughness are key to successfully resolving the WordPress redirect problem. Always back up your website before making changes, and don’t hesitate to seek professional assistance if needed. By following these steps, you’ll be on your way to a fully operational and SEO-optimized website on your new domain. Good luck!