• Home  
  • How to Migrate a WordPress Site to a New Host
- WordPress and Web Development

How to Migrate a WordPress Site to a New Host

Move your WordPress site to a new host without losing content. Back up first, copy files and database, update URLs safely, and test before you switch.

A laptop showing a plain website layout beside a printed moving checklist and a small stack of boxes on a tidy desk.

How to migrate a WordPress site to a new host? Copy your files and database to the new server, point the site at the new database in wp-config.php, and update the site URL wherever it is stored. WordPress does not need to be reinstalled when you move it. The work is careful rather than complicated: back up first, move the files and database together, replace the old domain safely, and test fully before visitors are sent to the new host. This guide follows the official WordPress.org migration documentation for single-site installations.

Key takeaways: back up files and database before anything moves; a same-domain move is a copy, not a reinstall; a domain change needs the URL updated in Settings and a safe search and replace; never change the GUID column; test everything on the new host before switching visitors over.

What a WordPress migration actually moves

A WordPress site is two things that must travel together: the files — WordPress core, themes, plugins, uploaded images and media, wp-config.php and .htaccess — and the database, which holds posts, pages, comments, settings, menus and links. Move only the files and you get an empty shell; move only the database and you get content with no design.

WordPress.org states the reassuring part plainly: whether you are moving WordPress to a new server or to a different location on your server, you do not need to reinstall. Most failures come from skipping the backup, moving half the site, or replacing the old domain with a careless database edit. Scope note: these directions are for single installs only; a Multisite network needs manual database editing.

Before you start: back up everything

Before you move anything, back up your WordPress directory, images, plugins and other files, as well as the database — that is the order WordPress.org gives. Keep the backup somewhere safe, away from the site. Make separate copies of wp-config.php and .htaccess, the two files you are most likely to edit; WordPress.org calls the .htaccess backup a requirement, not a recommendation. If you make a mistake, you can restore your database from your backup and try again — but only if the backup exists. Database edits are never risk-free, so if you are not comfortable editing a database directly, use the plugin route below.

Method 1: Migrate WordPress to a new host with the same domain

This is the simpler move, and the one most site owners need: moving the files without changing the Home and Site URLs. Visitors keep the same address, and nothing about the public site changes except where it is hosted.

  1. Back up the old site: the full WordPress directory plus a database export, kept safe.
  2. Copy the files and database to the new server: upload the whole directory and import the database export there.
  3. Update wp-config.php only if the database details changed: a new server, a renamed database, or a new database user.
  4. Test before you switch: temporarily change “siteurl” and “home” in the wp_options table, through phpMyAdmin or similar.
  5. Reconfigure permalinks when the site goes live: open Settings, then Permalinks, and save the structure again.

If your hosting plan is the reason for the move, read our guide to choosing WordPress hosting before you sign up with the new host.

Method 2: How to migrate a WordPress site when the domain changes too

Moving the site and changing your domain name or URLs at the same time needs more care, because references to the old domain stay in the database. WordPress.org gives this sequence, in order.

  1. Download your existing site files.
  2. Export your database.
  3. Move the backed up files and database into a new folder, somewhere safe. This is your site backup.
  4. On the old site, go to Settings, then General, and change the URLs to the new address. Save, and expect a 404 page — normal at this stage.
  5. Download your site files again.
  6. Export the database again.
  7. Edit wp-config.php with the new server’s MySQL database name, user and password.
  8. Upload the files to the new server.
  9. Import the database on the new server.

The pattern: the backup comes first, the URL change happens on the old site, and the files and database are downloaded a second time after the URL change, so the copies you upload already carry the new address. If the address changes, tell people the new one, and consider adding redirect instructions in your .htaccess file.

Update every old URL safely: WordPress database migration without breaking the site

Changing the domain is not finished when the files and database are in place. The old address is stored in many places in the database — post content, image links, the options table, widgets and plugin settings. A plain find-and-replace can break the site: some themes and widgets store values with the URL length marked. A safe replacement tool updates the stored length too. WordPress.org gives three safe options:

  • A search-and-replace plugin, if you can access your Dashboard: the documentation names Velvet Blues Update URLs and Better Search Replace.
  • WP-CLI, if your hosting provider has installed it: wp search-replace 'old-domain.example' 'new-domain.example' --skip-columns=guid.
  • The Search and Replace for WordPress Databases script from interconnectit: a third-party script, only if you are comfortable with database administration.

Never, ever, change the contents of the GUID column. That is WordPress.org’s own emphasis, and it is absolute. The GUID is the permanent Globally Unique Identifier of a post, used by feed readers to know whether they have shown an item before. Change it, and many feed readers will display your old content again as if it were new.

After the replacement, search the database for items left and check each one before changing it. Image links live in the post_content column, and widgets with outdated URLs can be edited under Appearance, then Widgets. Transients are safe to delete, as they are recreated on demand — but only with a backup in place first.

Fix wp-config.php and .htaccess after the move

wp-config.php holds the database connection: name, user, password and host. Back it up before editing, then change only the values that changed. WP_HOME and WP_SITEURL can hard-code the addresses if the admin screens are unreachable, but you cannot then edit them on the General settings page, so treat them as a repair tool, not a permanent setting. The database route does the same job in phpMyAdmin: back up the database, open wp_options, and change the option_value for siteurl and for home.

The other repair tool is the RELOCATE constant. Add define('RELOCATE', true); to wp-config.php, open wp-login.php on the new server, and log in — WordPress updates the Site URL automatically. Confirm both addresses in Settings, then General, then remove the RELOCATE line immediately. Leaving it is insecure: in some configurations it allows an attacker to change your site URL.

.htaccess: back it up first — a requirement, not a recommendation — copy your custom rewrites to a safe text file, re-save your permalinks, then check the new .htaccess file still holds your custom rules, restore them if needed, and test the redirects.

The export and import shortcut, and what it cannot do

There is a lighter way to move content between two WordPress sites. On the old site, go to Tools, then Export, choose all content, and download the file. On the new site, go to Tools, then Import, choose WordPress, and assign the authors. This copies posts, comments, pages, categories and custom fields without erasing anything already there. It does not move the site itself: theme, plugins, settings and media do not travel with an export file. Use export and import for content on a fresh install, and the full file-and-database move when you move a WordPress site to a new host.

Test before you switch

Do not cancel the old hosting or point the domain at the new server until the new copy passes this check.

CheckWhat to look for
Homepage and key pagesNo errors, no blank pages
Admin loginwp-admin opens and logs in
Internal linksNone still pointing at the old domain
Images and mediaNo broken images
PermalinksPosts open at their proper URLs
Forms and searchForms submit, search returns results
PluginsEvery needed plugin active and working
Menus and widgetsNavigation and widgets match the old site

Only when every row passes should you update the DNS records. Keep the old site and its backup for a few days afterwards.

Common migration mistakes

MistakeWhat goes wrongHow to avoid it
Skipping the backupNothing to restoreBack up files and database first
Changing the GUID columnFeed readers resurface old posts as newNever touch GUID; use –skip-columns=guid
Plain SQL search and replaceSerialized theme and widget data breaksUse a safe replacement tool or plugin
Leaving RELOCATE in wp-config.phpSite URL can be changed by an attackerRemove the line once the move works
Forgetting permalinks and .htaccessPosts return 404 errorsRe-save permalinks
Cancelling the old host too soonNo way back if the new site failsKeep the old site live until tests pass

Once the site runs well on its new host, lock it down with our WordPress security hardening checklist, covering updates, logins, roles and file permissions. If the move also changed the look of the site, our guide to choosing a WordPress theme explains how to judge a theme before you activate it. Browse the WordPress and Web Development archive for more guides, and read about WebReOn Agency on our About Us page.

Frequently asked questions

Can I move a WordPress site without reinstalling it?

Yes. WordPress.org states you do not need to reinstall when moving WordPress to a new server or a different location on your server. Copy the files and the database, reconnect them in wp-config.php, and update the site URL.

Do I need a migration plugin to move my site?

No. The manual method — copying the files, exporting and importing the database, and updating the URL — is the method the official documentation describes first. A plugin is one route, not the only route.

Why does my site show a 404 error after I change the URL?

If you changed the URLs in Settings, then General, before moving the files, a 404 page is expected — the files do not live at the new address yet. Finish the move, then re-save your permalink structure so WordPress writes a fresh .htaccess file.

Will moving hosts hurt my search rankings?

If the domain and page URLs stay the same, the move itself does not change your addresses. If the domain changes, add redirect instructions in your .htaccess file so each old address guides visitors to the matching new one.

Sources and Further Reading

1 Comment

Leave a comment

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