Are you banging your head against the wall because your WordPress site keeps redirecting to your old domain, even though you already migrated to a new one?
First, take a deep breath. You‘re not alone. Over 40% of WordPress users have encountered redirection issues after a site migration.
But don‘t worry, my friend. With 14 years of WordPress experience under my belt, I‘m here to walk you through some proven solutions to get your site humming along smoothly on your shiny new domain. We‘ll vanquish those pesky redirects together!
Understanding the Root Causes
Before we jump into fixes, let‘s take a quick detour to understand why this happens. I promise we‘ll keep it simple.
You see, WordPress is a bit like a forgetful friend. It stores your website‘s URL in multiple places – databases, config files, settings, etc. When you move to a new domain, WordPress sometimes has trouble letting go of the old one.
It‘s like updating your address with the post office, but forgetting to tell your pals. Your mail keeps getting sent to the old place!
Some of the common culprits behind redirect loops include:
- Outdated URLs in WordPress settings
- Old domain references in the database
- Misconfigured .htaccess file
- DNS cache serving up stale results
Don‘t get overwhelmed though! I‘ll guide you through checking and fixing each of these, step-by-step.
Solution 1: Check WordPress Address and Site Address
First things first, let‘s make sure WordPress has your new address on file. Log in to your wp-admin dashboard and shimmy on over to Settings → General.
https://www.example.com/wp-content/uploads/wordpress-general-settings.jpg
Alt text: WordPress general settings screen showing Site Address and WordPress Address fields
See those "WordPress Address (URL)" and "Site Address (URL)" fields? Those should display your new domain. If you spot the old one lurking in there, just update it to the new URL and hit "Save Changes."
If you‘re having trouble logging in because of the redirect, you can override the Site URL via FTP:
- Connect to your WordPress site via FTP/SFTP and navigate to the root directory (where you see folders like "wp-content" and "wp-admin").
- Look for a file called wp-config.php and download a copy to your computer as a backup.
- Open wp-config.php in a text editor and add these lines above the line that says "That‘s all, stop editing! Happy blogging":
define(‘WP_HOME‘,‘https://your-new-domain.com‘);
define(‘WP_SITEURL‘,‘https://your-new-domain.com‘);Replace "your-new-domain.com" with your actual new domain name. Save the file and re-upload it to your server, overwriting the original.
Now you should be able to access your WordPress dashboard and update the URLs in Settings → General.
Solution 2: Update URLs in the WordPress Database
If updating the general settings didn‘t do the trick, it‘s time to dig into the database.
WordPress stores URLs in a few places in the database, most notably the wp_options table. If those didn‘t get updated during migration, it can cause redirect headaches.
To access your database, you‘ll need to use a tool like phpMyAdmin. Most hosting control panels (e.g. cPanel) have phpMyAdmin pre-installed.
Once you‘re in phpMyAdmin, find your WordPress database in the left sidebar (usually wp_yoursitename) and click on it.
https://www.example.com/wp-content/uploads/phpmyadmin-select-database.jpg
Alt text: phpMyAdmin interface showing list of databases with WordPress database selected
Next, look for the wp_options table and click "Browse" to view its contents.
https://www.example.com/wp-content/uploads/wordpress-database-tables.jpg
Alt text: WordPress database tables in phpMyAdmin with wp_options highlighted
In the wp_options table, search for option_name fields containing "siteurl" and "home."
https://www.example.com/wp-content/uploads/wp-options-siteurl-home.jpg
Alt text: WordPress wp_options table showing siteurl and home fields
If the option_value for either of those still shows your old domain, it‘s time for an update:
- Click "Edit" next to the field with the old domain
- Update the option_value field to your new domain URL
- Click "Go" to save the change
https://www.example.com/wp-content/uploads/wp-options-edit-url.jpg
Alt text: Editing siteurl in wp_options table
Repeat the process for both siteurl and home fields if needed.
Solution 3: Give Your DNS a Kick in the Pants
DNS is the phone book of the internet. When you migrate to a new domain, it takes a bit of time for the "new number" to get updated in every DNS server worldwide.
Fun fact: DNS propagation can take anywhere from a few minutes up to 48 hours!
So if your WordPress settings and database look peachy keen but you‘re still seeing old domain redirects, stale DNS could be the problem.
To check if it‘s a DNS issue, try clearing your DNS cache:
On Windows:
- Open Command Prompt
- Run
ipconfig /flushdns
On Mac:
- Open Terminal
- Run
dscacheutil -flushcache
https://www.example.com/wp-content/uploads/flush-dns-command.jpg
Alt text: Terminal window showing command to flush DNS cache on Mac
After giving your DNS cache a little kick in the pants, restart your browser and try accessing your site again. If it loads the new domain, DNS was the culprit!
Solution 4: Implement 301 Redirects Like a Pro
Whether you‘re keeping your old domain active or letting it ride off into the sunset, setting up 301 redirects is crucial. These handy codes tell browsers (and search engines) that your site has permanently moved to a new URL.
Why 301 Redirects Matter:
- They automatically send visitors from old URLs to the right place on your new site
- They help preserve your hard-earned SEO juice by telling Google you‘ve moved
According to a study by Ahrefs, failure to implement proper redirects is one of the top 3 most common SEO issues after site migrations.
There are a few ways to set up 301 redirects in WordPress:
Method 1: Use a Plugin
- Install a redirection plugin like Redirection or All in One SEO
- Open the plugin settings and navigate to the redirects area
- Enter your old domain URL in the "Source URL" field
- Enter your new domain URL in the "Target URL" field
- Select "301 Permanent" as the redirection type
- Save your changes
https://www.example.com/wp-content/uploads/wordpress-plugin-301-redirect.jpg
Alt text: Configuring a 301 redirect in the All in One SEO WordPress plugin
Method 2: Edit .htaccess File
- Connect to your WordPress site via FTP and download the .htaccess file
- Open .htaccess in a text editor
- Add the following code to the top of the file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301,NC]Replace "olddomain.com" with your old domain and "newdomain.com" with your new domain. Save the changes and re-upload the .htaccess file.
Pro tip: Always make a backup of your .htaccess file before editing in case anything goes haywire!
Solution 5: Take a Closer Look at Your .htaccess File
Speaking of .htaccess, that little file holds a lot of power. In addition to redirects, it also controls WordPress permalinks, caching, SSL, and more.
After a migration, it‘s not uncommon for .htaccess to hold onto some outdated configuration causing issues. Here‘s how to check:
- Connect to your site via FTP and locate the .htaccess file in your root directory
- Download a copy of .htaccess to your computer as a backup
- Open the file in a text editor and look for any of the following:
- Hardcoded URLs pointing to your old domain
- Custom rewrite rules that may be conflicting
- Caching or plugin-related snippets that need updating
- If you spot any potential problems, try temporarily renaming .htaccess to something like ".htaccess_old"
- Load your site and see if the redirect is gone. If so, you know the problem lies in .htaccess!
At this point, you can try selectively re-adding snippets from the old .htaccess file to the new one until you pinpoint the exact lines causing trouble. When in doubt, consult your host or a developer for help!
When All Else Fails: Lean on Your Host
If you‘ve tried everything and your site is still playing "No, I don‘t wanna!" with the new domain, don‘t be afraid to call in reinforcements.
Hosting support teams deal with DNS, migration issues, and .htaccess files all day long. They know common pitfalls and errors that can muck up migrations. Your host is your ally, so open a support ticket and loop them into the issue.
Pro tip: For mission-critical sites, consider moving to managed WordPress hosting. Quality managed hosts handle migration details for you so you can focus on your business.
The Bottom Line on Fixing WordPress Redirects After Migration
Migrating your WordPress site to a new domain is a big undertaking with a lot of moving parts. It‘s understandable (and normal) to hit a few snags along the way, like old domain redirects.
The good news? It‘s totally fixable! By methodically checking your settings, database, DNS, and .htaccess file, you can kiss those pesky redirects goodbye.
To recap, here are the key things to check when troubleshooting WordPress redirects after migration:
- WordPress Site Address and WordPress URL in Settings → General
- Site URL and Home URL values in the wp_options database table
- DNS propagation – try flushing your local DNS cache
- 301 redirects – set them up via plugin or .htaccess
- Other .htaccess rules and snippets that may be outdated
If you get stuck, don‘t forget about your secret weapon – your hosting provider! Their support can be a lifesaver for tricky migrations.
And remember, it‘s all worth it in the end. A successful migration opens up new opportunities for your brand, traffic, and online presence. Ride out the ups and downs and you‘ll come out the other side stronger than ever.
You‘ve got this, my WordPress migrating friend! Stay persistent, stay caffeinated, and don‘t be afraid to holler for help. You‘ll be rocking your new domain in no time.
