WordPress Redirecting to Old Domain After Moving Files

WordPress Redirecting to Old Domain After Moving Files

Here’s How to Fix It

Moving a WordPress website to a new domain can seem straightforward: copy the files, move the database, update a few settings, and point the domain’s DNS records to the new server.

Then you visit the new website—and WordPress sends you straight back to the old domain.

This is a common migration problem, particularly when files have been moved but the old domain is still stored somewhere in the WordPress configuration or database. In some cases, the redirect can also be caused by caching, `.htaccess`, a security plugin, or server configuration.

The good news is that the problem is usually fixable without rebuilding your website. The key is to identify where WordPress is getting the old domain from and correct it systematically.

WordPress Redirecting to Old Domain After Moving Files

The Core Basics

When WordPress is installed, it stores important information about your website’s address. Two settings are particularly important:

* WordPress Address (URL) — the location where the WordPress core files are installed.
* Site Address (URL) — the public address visitors use to access your website.

For example, if your website has moved from `oldsite.com` to `newsite.com`, WordPress needs to know that `newsite.com` is now the correct address.

The problem occurs when the old domain remains in one of these settings, the WordPress database, configuration files, or server rules.

There is another important distinction. Moving WordPress files does not automatically change the domain stored in WordPress. Your website can physically exist on a new server while WordPress still believes its official address is the old domain.

Other possible causes include:

* Old URLs stored throughout the database
* A hard-coded domain in `wp-config.php`
* Redirect rules in `.htaccess`
* Caching plugins
* Server-level redirects
* CDN or DNS configuration
* SSL or HTTPS configuration
* Domain forwarding at your registrar

Understanding these possibilities makes troubleshooting much easier.

💡 WP Fix It Co Recommendation: If you are dealing with wordpress redirecting to old domain after moving files, having fast, secure WordPress hosting can help prevent configuration and performance problems and make migration and troubleshooting much smoother. Get Hostinger WordPress Hosting here.

Step-by-Step Guide to Stop WordPress Redirecting to the Old Domain

1. Check the WordPress URL Settings

The first place to look is the WordPress database.

If you can access your WordPress dashboard, go to:

Settings → General

Look for:

* WordPress Address (URL)
* Site Address (URL)

Both should normally contain your new domain.

For example:

`https://newsite.com`

Make sure there is no reference to the old domain.

If WordPress redirects you before you can access the dashboard, don’t worry. You can change these values directly through the database or temporarily define them in `wp-config.php`.

WordPress Redirecting to Old Domain After Moving Files

 

2. Check `wp-config.php`

Connect to your website using your hosting file manager or FTP.

Open the WordPress installation directory and locate:

`wp-config.php`

Look for definitions such as:

“`php
define(‘WP_HOME’, ‘https://oldsite.com’);
define(‘WP_SITEURL’, ‘https://oldsite.com’);
“`

If these exist, they can override the settings stored in the WordPress database.

Change them to your new domain:

“`php
define(‘WP_HOME’, ‘https://newsite.com’);
define(‘WP_SITEURL’, ‘https://newsite.com’);
“`

Save the file and test your website.

If these lines aren’t present, don’t add them unless you have a reason to use them. The database settings may be sufficient.

3. Check the Database

If the problem continues, the old domain may still be stored in the WordPress database.

Using phpMyAdmin, locate the database used by your WordPress installation.

The table is commonly called:

`wp_options`

However, your installation may use a different table prefix.

Look for the records:

* `siteurl`
* `home`

Both should point to your new domain.

For example:

`https://newsite.com`

If they still contain the old domain, update them carefully.

Always back up the database before making direct database changes.

4. Search for the Old Domain Throughout the Database

Changing `home` and `siteurl` may solve the redirect, but migrated websites can contain hundreds or thousands of references to the previous domain.

These can appear in:

* Posts
* Pages
* Menus
* Widgets
* Theme settings
* Plugin settings
* Image URLs
* Custom fields

A simple find-and-replace operation can update these references.

However, be careful when performing database-wide replacements. WordPress plugins and themes can contain serialized data, and poorly executed replacements can corrupt that information.

Use a reputable WordPress migration or search-and-replace tool that understands serialized data rather than blindly replacing text in a database export.

5. Inspect `.htaccess`

Another frequent cause is a redirect rule left behind from the old website.

For an Apache-based WordPress installation, look for the `.htaccess` file in your site’s root directory.

A standard WordPress `.htaccess` file may look similar to:

“`apache
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress
“`

Look for unusual rules containing the old domain.

For example, a rule that explicitly redirects visitors to `oldsite.com` could be responsible.

Back up `.htaccess` before editing it.

If you’re unsure about a rule, don’t delete it blindly. A hosting support technician or WordPress developer can help determine whether it is necessary.

6. Clear Every Relevant Cache

Caching can make a fixed redirect appear to continue.

Clear:

* WordPress caching plugin
* Hosting cache
* CDN cache
* Browser cache
* Server-side cache

Then test the website again.

It’s also useful to test in a private/incognito browser window. This helps eliminate cached browser information from the equation.

7. Check Your Domain and DNS Settings

Your WordPress installation isn’t the only place that can cause a redirect.

Log into your domain registrar and check whether domain forwarding is enabled.

You should also check your DNS records.

The new domain should point to the server where the migrated WordPress website is actually hosted.

If the old domain has forwarding enabled, visitors can be redirected before WordPress even gets a chance to process the request.

8. Temporarily Disable Plugins

If the redirect persists, a plugin could be responsible.

This is particularly possible with:

* Redirection plugins
* Security plugins
* SEO plugins
* SSL plugins
* Caching plugins
* Migration plugins

If you cannot access the WordPress dashboard, you can temporarily disable plugins through the hosting file manager.

Navigate to:

`wp-content/plugins`

You can temporarily rename the `plugins` folder to something such as:

`plugins-disabled`

WordPress will then be unable to load the installed plugins.

Test the website.

If the redirect disappears, restore the folder name and reactivate plugins individually to identify the culprit.

9. Check SSL and HTTPS Configuration

If you moved from one domain to another and changed HTTP/HTTPS settings at the same time, SSL configuration can complicate the migration.

Make sure your new domain has a valid SSL certificate and that your website consistently uses the correct HTTPS address.

For example, avoid having different components attempting to force:

`http://newsite.com`

and

`https://oldsite.com`

at the same time.

10. Test Before Assuming the Problem Is WordPress

Finally, determine exactly where the redirect occurs.

Try accessing:

* The homepage
* `/wp-admin`
* `/wp-login.php`
* A specific post
* A specific image

If everything immediately redirects to the old domain, the problem may be at the WordPress or server configuration level.

If only certain pages redirect, an individual plugin, database entry, or redirect rule may be responsible.

Best Practices and Pro Tips

Always create a full backup before changing WordPress files or database settings. Ideally, keep a copy of the original files and database until the migration has been confirmed successful.

When changing domains, make a migration checklist covering WordPress URLs, database references, `.htaccess`, redirects, SSL, DNS, plugins and caching.

Don’t make several major changes simultaneously. Change one thing, test the website, and then move to the next step. This makes identifying the cause considerably easier.

Also remember that DNS changes can take time to propagate. If you’ve only just changed the domain’s DNS records, give the changes time to reach different networks.

Common Mistakes to Avoid

1. Changing Only the WordPress Files

Copying the files doesn’t change the domain stored in WordPress.

2. Editing the Database Without a Backup

A small database mistake can cause much bigger problems. Always create a backup first.

3. Forgetting `.htaccess`

An old redirect rule can continue sending visitors to the previous domain even after WordPress has been correctly configured.

4. Ignoring Caching

A cached redirect can make you think your changes haven’t worked. Clear all relevant caches before troubleshooting again.

Conclusion

If you encounter wordpress redirecting to old domain after moving files, don’t panic. In most cases, the website itself hasn’t been lost—the old domain is simply still being referenced somewhere in the WordPress, database, hosting, or domain configuration.

Start with the WordPress URL settings and `wp-config.php`, then check the database, `.htaccess`, plugins, caching, DNS and SSL configuration.

Work methodically and make backups before changing anything important.

For more practical WordPress troubleshooting guides, fixes and beginner-friendly tutorials, keep exploring WP Fix It Co.

Leave a Comment

error: Content is protected !!