Professional Documents
Culture Documents
Moving WordPress
Interested in functions, hooks, classes, or methods? Check out the new
WordPress Code Reference!
If you are moving WordPress from one server to another, begin by backing
up your WordPress directory, images, plugins, and other files on your site
as well as the database. See WordPress Backups and Backing Up Your
Database.
Moving your domain without changing the Home and Site URLs of your
WordPress site is very simple, and in most cases can be done by moving
the files.
If database and URL remain the same, you can move by just copying
your files and database.
If database name or user changes, edit wp-config.php to have the
correct values.
If you want to test before you switch, you must temporarily change
"siteurl" and "home" in the database table "wp_options" (through
phpMyAdmin or similar).
If you had any kind of rewrites (permalinks) setup you must disable
.htaccess and reconfigure permalinks when it goes live.
https://codex.wordpress.org/Moving_WordPress Pagina 1 di 10
Moving WordPress « WordPress Codex 08/06/18, 17)29
Moving a website and changing your domain name or URLs (i.e. from
http://example.com/site to http://example.com, or http://example.com to
http://example.net) requires the following steps - in sequence.
When your domain name or URLs change there are additional concerns.
The files and database can be moved, however references to the old
domain name or location will remain in the database, and that can cause
issues with links or theme display. This site highlights the MySQL
commands and respective tables needed to be search-replaced.
If you do a search and replace on your entire database to change the URLs,
you can cause issues with data serialization, due to the fact that some
themes and widgets store values with the length of your URL marked.
When this changes, things break. To avoid that serialization issue, you
have four options:
1. Use the Velvet Blues Update URLs plugin if you can access your WP
Admin Dashboard.
https://codex.wordpress.org/Moving_WordPress Pagina 2 di 10
Moving WordPress « WordPress Codex 08/06/18, 17)29
2. Use the Better Search Replace plugin if you can access your WP
Admin Dashboard.
3. Use WP-CLI's search-replace if your hosting provider (or you) have
installed WP-CLI.
4. Use the Search and Replace for WordPress Databases Script to safely
change all instances on your old domain or path to your new one. (**
only use this option if you are comfortable with database
administration ** )
address.
6. Click Save Changes.
7. (Do not try to open/view your site now!)
8. Move your WordPress core files to the new location. This includes the
files found within the original directory, such as
http://example.com/wordpress, and all the sub-directories, to the
new location.
9. Now, try to open your site by going to yourdomain.com/wp-admin.
Note, you may need to go to yourdomain.com/wp-login.php
10. If you are using Permalinks, go to the Administration > Settings >
Permalinks screen and update your Permalink structure to your
.htaccess file, which should be in the same directory as the main
index.php file.
11. Existing image/media links uploaded media will refer to the old folder
and must be updated with the new location. You can do this with the
Velvet Blues Update URLs or Better Search Replace plugins, WP-CLI's
search-replace if your hosting provider (or you) have installed WP-
CLI, manually in your SQL database, or by using the 3rd party
database updating tool Search and Replace Databases Script * Note:
this script is best used by experienced developers.
12. In some cases your permissions may have changed, depending on
your ISP. Watch for any files with "0000" permissions and change
them back to "0644".
13. If your theme supports menus, links to your home page may still have
the old subdirectory embedded in them. Go to Appearance > Menus
and update them.
14. Sometimes you would need to restart your server, otherwise your
server may give out an error. (happens in MAMP software (Mac)).
It is important that you set the URI locations BEFORE you move the files.
https://codex.wordpress.org/Moving_WordPress Pagina 4 di 10
Moving WordPress « WordPress Codex 08/06/18, 17)29
If you accidentally moved the files before you changed the URIs: you have
two options.
https://codex.wordpress.org/Moving_WordPress Pagina 5 di 10
Moving WordPress « WordPress Codex 08/06/18, 17)29
update_option('siteurl', 'http://your.domain.name/the/path' );
update_option('home', 'http://your.domain.name/the/path' );
You're done. Test your site to make sure that it works right. If the change
involves a new address for your site, make sure you let people know the
new address, and consider adding some redirection instructions in your
.htaccess file to guide visitors to the new location.
Changing The Site URL also provides the details of this process.
It's possible, but unlikely, that the upload_path option value may be set on
some very old WordPress sites, or on sites where the designer needed to
customize this path. In this case, you should verify that the path is still
valid after the move, and adjust it as it needed. If an absolute rather than a
relative path was used, the path may be incorrect for use on the new server.
An incorrect upload path will result in problems with media uploads and
possible filesystem errors when WordPress attempts to create upload
directories on the wrong path. (See ticket ticket #41947.)
Normally, the upload_path value may be blank and WordPress will use the
default path. If the value is not blank and contains a value other than the
default upload location, you may need to do further research to determine
how to handle uploads on the site after the move.
https://codex.wordpress.org/Moving_WordPress Pagina 6 di 10
Moving WordPress « WordPress Codex 08/06/18, 17)29
1. Download a copy of the main wordpress files from your OLD site to
your hard drive and edit wp-config.php to suit the new server.
2. Go back to your OLD site and go to Administration > Settings >
General and change the URL (both of them) to that of your new site.
3. Login on your server, go to phpMyAdmin, export as file, and save your
database (but keep the old one just in case). Now, upload this new
database and the copy of the wordpress core files with the edited wp-
config.php to your new server. That's it!
Keeping it Running
Caution: Make sure you have a backup of your old site's WordPress
database before proceeding!
https://codex.wordpress.org/Moving_WordPress Pagina 7 di 10
Moving WordPress « WordPress Codex 08/06/18, 17)29
Note: using this method, if there are some articles in the new site (like
Hello World, Info Page, etc.), these will not be erased. Articles are only
added. Using the former procedure, the articles in new site will be
deleted.
https://codex.wordpress.org/Moving_WordPress Pagina 8 di 10
Moving WordPress « WordPress Codex 08/06/18, 17)29
If, instead, you are changing domains, then the best way to move Multisite
is to move the files, edit the .htaccess and wp-config.php (change
DOMAIN_CURRENT_SITE and, if the folder name containing Multisite
changed, PATH_CURRENT_SITE), and then manually edit the database.
Search for all instances of your domain name, and change them as needed.
This step cannot yet be easily automated. It's safe to search/replace any of
the wp_x_posts tables, however do not attempt blanket search/replace
without the Search and Replace for WordPress Databases script (aka the
interconnectit script).
If you're moving Multisite from one folder to another, you will need to
make sure you edit the wp_blogs entries to change the folder name
correctly. You should manually review both wp_site and wp_blogs
regardless, to ensure all sites were changed correctly.
Also, manually review all the wp_x_options tables and look for four fields
and edit them as needed:
home
siteurl
upload_path
upload_url_path
The upload path and URL will be empty if the default media paths are
used.
https://codex.wordpress.org/Moving_WordPress Pagina 9 di 10
Moving WordPress « WordPress Codex 08/06/18, 17)29
to adjust the .htaccess file and the value for SUBDOMAIN_INSTALL in your
wp-config.php file accordingly.
Related Links
eduChalk: How to Move WordPress to a Different Server and Web
Address, 2-part video series
How to move WordPress site to another server with zero downtime
Moving a blog from wordpress.com to self-hosted blog
Moving WordPress to a new domain or server
Italian version of this article - Versione italiana dell'articolo
Search and Replace for WordPress Databases
Cloning a live WordPress site to a local Mac test environment
PHP script to replace site url in Wordpress database dump, even with
WPML
The Duplicator plugin helps administrators move a site from one
location to another
This article is marked as in need of editing. You can help Codex by editing
it.
https://codex.wordpress.org/Moving_WordPress Pagina 10 di 10