How to set up smartphones and PCs. Informational portal
  • home
  • Mistakes
  • Blog transfer to another hosting. Changing Configuration File Options

Blog transfer to another hosting. Changing Configuration File Options

Good afternoon dear readers. The other day I told you how to do it on another hosting without changing the domain. Today I want to complete this story with a post on how to make wordpress migration to another domain with or without hosting change.

Page navigation:

You probably know that if you just take and send a new domain to the site, then the admin panel and certain parts of the site will open from the old domain + the menu will constantly fail, throwing it to the wrong place. There are 2 ways to solve this problem, fix the database dump or use the magic lines of code for the WordPress wp-config.php file:

define("WP_HOME", "http://newdomain.ru");
define("WP_SITEURL", "http://newdomain.ru");

Before any actions to transfer the site or change the domain, make a full backup of the working site!!!

This code completely solves the problem of transferring from a new domain to an old one and forces the WordPress admin panel to load from a new address, but unfortunately it cannot change all links inside posts, pages, taxonomies, widgets, and so on. In fact, this PHP code replaces the domain that is registered in your settings, wordpress is not transferred to another domain: and you can simply change the domain in the settings so as not to add code to wp-config.php.

But today is not about that, we need to do complete replacement old domain to the new one.

To transfer wordpress to another domain, we need the following tools:

Name Description Link
(first click generate link,
second open in a new tab)
FileZilla- free FTP client FTP client for working with files and directories on your hosting.
Administrator php file for download mySQL databases. You can use the built-in phpMyAdmin on your hosting, if it is, of course, but I will describe universal option using this file.
Notepad++ Stylish and convenient editor files. Head and shoulders above the regular text editor in Windows.

wordpress domain change

To change the domain in WordPress, we need to download a database dump. This can be done using the PHP file Adminer or using the phpMyAdmin hosting panel.

Step-by-step instructions for changing the domain in WordPress:

1) download Adminer from the link above and upload it via FTP to your hosting. To do this, we need a FileZilla FTP client, as well as FTP access to your hosting. We launch ftp client FileZilla and enter our ftp data as shown in the screenshot:

2) in the right column we have files from the server, and in the left column we have files from our PC. In the left column you need to find the folder where adminer-4.2.2.php is located (by the way, you may have a slightly different name), and in the right column you need to find the directory where our site is located, there will be files "wp-config.php", " index.php", directories "wp-content", "wp-admin", "wp-includes" and upload the admin to the server.

3) Open the browser and type your site.com/adminer-4.2.2.php there (replace it with your own version) a page of the following plan should open: 4) If you know these data that the admin asks for, then enter them, if not, then open the wp-config.php file, it is in the root of your site and take the necessary database access data, as shown in the figure:

5) enter data in the login form and click enter, we should have a window like this:


6) click on the export tab on the left: and we will open like this (do not rush to save the base, there are a couple of nuances, we will go further about them)

7) you can download the entire database and then mess with replacing the yurls, or you can split it into 2 parts and avoid problems. In the first part of the database we include all tables except "wp_comments" and "wp_posts" look carefully at the skin below:


and click export. We save the file, be sure to indicate that this is the first part, for example, add the number 1 to the name: Now we are doing the second part for this, in the same export, we need to put cherboxes only near the "wp_comments" and "wp_posts" tables, see the skin:
and again press export only add the number 2 to the name:

8) Open the first part of the database in Notepad ++, which should already be installed on our PC: and press the key combination Ctrl + f, in this window we write our domain in the search box and press Enter:
we continue the search until we find data like this:

"siteurl", "http://site"

""home", "http://site"

Be very careful, in the first part we only have to replace the links to the new domain here, I'm attaching the skin:
as you understand, you need to replace the old domain with a new one in these places. We save the first part of the base and close it so that it does not get confused at hand.

9) Open the second part in Notepad++ and do a slightly different thing. Press Ctrl+f again, but in the search go to the second tab "Replace" and fill in the same as on my skin:

All posts have changed their domain, now we need to save this dump and close it.

10) We return to our admin, go to the import tab and first fill in the first part of the dump, then the second one in turn:

11) After successfully uploading both parts of the dump to the database, your site has changed Domain name, and if you previously sent the DNS of the new domain to your hosting, then the site will open with a new domain name, the wordpress domain change was successful, the wordpress transfer to another domain was completed.

12) We go to the admin panel, the first tab of the settings is "general" (your site / wp-admin / options-general.php) we look at whether the domain is correct in both fields and click save changes while we did not make any changes. That's it, now your site will work from the new domain.

Moving wordpress to another domain

Theoretically, I have already told how to transfer wordpress to another domain, more precisely here (hereinafter I will call this step-by-step instruction as "Instruction 1"), I told how to transfer the WP to another hosting, and in the title (I will call it "Instruction 2" further on) I described how to do a WordPress domain change. It remains only to structure everything described.

And so, a structured step-by-step instruction:

1) From "Instructions 1" we make all the points from the first to the fifth (1 - 5) inclusive.

3) As a result of these actions, we have all the files from the old hosting and a 2-part database from the old hosting, in which the new domain is already recorded.

4) This instruction implies that you have already screwed the new domain to the new hosting, I will not describe this process. We are connecting to a new hosting, there we should have a made base and the site itself is screwed (created folders where to upload files via FTP). From "Instruction 1" you need to do steps 13 to 15 inclusive.

5) In "Instruction 1" in paragraph 16 it says that you need to fill in 1 part of the database, we have 2 parts, that is, we fill in turn the first and second parts of the database.

6) That's all, the transfer of wordpress to another domain is completed and we can enjoy its work.

In this manual, I simplified everything a bit, did not describe everything in a new way, because transferring wordpress to another domain and transferring a wordpress site to another hosting are quite similar tasks. The main thing for you to understand is that you need to download from the old hosting not 1 whole dump, but 1 dump divided into 2 parts. Well, from here it follows that you will need to upload 2 parts of one database dump to the new hosting. + In these parts, you need to know how and where to change the domain to a new one. We have transferred wordpress to another domain, if something didn’t work out for you, you can contact me and I will help you.

Sometimes the site administrator is faced with the need to change the domain. Transferring a WordPress site from one domain to another has some peculiarities. It is not enough just to transfer the files to the root directory of the new domain, import the database and set up a connection to it in configuration file. WordPress is linked to a domain and it is necessary to make changes to the site settings in order for it to work from a new domain. In this article, I will tell you in detail step by step how to do this simply and without any consequences.

Transferring files and site database to WordPress from one domain to another

The first step is to get the initial site data, namely to save the site files and the database. Consider this on the example of Machost hosting.

1. We create and save site files, this can be done through the File Manager:
Go to the root directory of the old domain, select all files from the root directory and create an archive. The saved archive is downloaded to your computer. You can also use to download files.

2. Exporting the database dump. To do this, go to phpMyAdmin, select the database in the left list and click on the button on top Export

More: Archives of files and site databases in MacHost can be done automatically from the Backup copies menu, Create a backup section. The files will be placed in the private directory

Now that you have the source files of your site, you can proceed to the second stage: this is the transfer of data to a new domain and setup. I advise you to make a copy of them and save them separately, in case 3. Go to the root directory of the new domain and download the archive. Again, this can be done via file manager hosting control panel, and via FTP. The file can be unpacked in a file manager
4. We import sql dump into the database through phpMyAdmin. To do this, after logging into phpMyAdmin of the required database, select the database in the left list and then click on the button in the top panel Import

5. In the site config file wp-config.php of the new domain, write down the information for connecting to the database.

Change Domain in WordPress Settings

After the transfer, as a rule, images are not displayed on the site, as if there are no style files. Links go to the old domain. This is a feature of the WordPress engine, to complete the transfer, you need to make changes to the database, namely, change the links of the old domain to the new one. This can be done in several ways.

Change domain in WordPress using phpMyAdmin

We go into phpmyadmin of the database to which your site is connected. Be sure to select the database in the left list and press the SQL button, as shown in the screenshot

One by one or all three at once, copy and execute the queries below, correcting the parameters

UPDATE wp_options SET option_value = REPLACE(option_value, "http://old-domain.ru", "http://new-domain.ru") WHERE option_name = "home" OR option_name = "siteurl"; UPDATE wp_posts SET guid = REPLACE(guid, "http://old-domain.ru","http://new-domain.ru"); UPDATE wp_posts SET post_content = REPLACE(post_content, "http://old-domain.ru", "http://new-domain.ru");

Important! You need to register the domain without a slash / at the end, as indicated in the example.
The request will not be executed if you have a prefix in the tables notwp_, and the other.
If for example you have a prefixpref_, then write it in the request code: UPDATE pref_posts SET ...

Changing the domain in Wordpress in sql-dump through a text editor

Another way to update information in the database is to manually replace links from the old domain to the new one. Log in with phpMyAdmin to the database of the old domain and export if you have already done so. Open the resulting sql file with a text editor and search, replacing all references to the old domain with the new one. After updating the information, import the dump into the hosting database, having previously cleared it of old tables.

This completes the transfer and setup.

Sometimes a situation may arise when you need a website running on the engine WordPress, move to a new domain. Those. the essence of this action is only in domain name change, all the content, as well as the link structure, remains the same. At the same time, not an unimportant moment - preservation of TCI and PR indicators.

This issue must be approached full understanding affairs, because the opposite can be fraught with unpleasant consequences.

The transfer process can be divided into 2 parts:

  1. Transferring a site running on WordPress engine, to the new domain.
  2. Creating a 301 redirect from the old domain to the new one.

Transferring a WordPress site to a new domain

First of all, you need to do 2 things:

  • copy all ftp files from the old domain to the new one;
  • necessarily create a backup copy of the site database so that in which case you can roll back.

Further actions can be performed in one of the three following ways.

First way

This is the easiest way, requiring the least action from you.

  1. Go to the admin panel of your site on the page "Settings - General".
  2. In the fields « WordPress address» and "Website address" specify the URL of the new domain and confirm the changes by clicking on the button "Save Changes".
  3. Ready. At the same moment, WordPress redirects you to the admin login page, but on a new domain.

Second way

  1. Open the saved sql dump of the database in a text or PHP editor.
  2. Replace all occurrences of the old site address with new address , eg, http://domain.ru replaced by http://newdomain.ru, and save your changes.
  3. Upload the dump to the database on the server, after deleting all existing tables from it.
  4. Ready. The WordPress site is working at a new address.

Third way

  1. Login to phpMyAdmin and select a database.
  2. Click on the " SQL” and execute the following 3 queries in turn, replacing http://domain.ru and http://newdomain.ru respectively to the old and new site addresses (note that at the end of the address there shouldn't be a slash):

      UPDATE wp_posts SET guid = replace(guid, "http://domain.ru","http://newdomain.ru");

      UPDATE wp_posts SET post_content = replace(post_content, "http://domain.ru", "http://newdomain.ru");

  3. Ready. Now the site will open at the new address.

Creating a 301 redirect from the old domain to the new one

It remains to ensure that when accessing any page of the site at the old address, the visitor is automatically redirected to the same page in the new domain.

For this it is necessary replace the contents of the .htaccess file located at the root old domain, to the following (instead of newdomain.ru, the new domain is indicated):

Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://newdomain.ru/$1

At this point, the procedure for transferring a WordPress site to a new domain can be considered complete.

Now a few words about maintaining indicators of the TCI and PR of the site.

The above directive, in addition to its direct purpose, allows you to transfer the indicator to a new domain Google PR, so there shouldn't be any problems with PR.

However, the question of transferring the indicator remains open to me. TIC Yandex. I have read enough information about this, but have not found an unambiguous solution. Basically, it is recommended to create a file on the old domain robots.txt with the parameter Host: newdomain.ru , it will not work because of the 301 redirect.

I would be grateful to someone who can clarify this issue for me.

Added on 04/24/2010

I found the answer to my own question. So that when accessing the old domain, a 301 redirect would work, but with the exception of the file robots.txt, in file .htaccess old domain you need to specify the following:

Rewrite Engine off Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://newdomain.ru/$1

And in the robots.txt file, specify the following:

User-Agent: * Disallow: Host: newdomain.ru

Web developers, one way or another, may face the problem of transferring a site running on WordPress to another domain or hosting. There will be no problems with transferring the site to another hosting while maintaining the same domain name. The main thing is that the new hosting supports those system characteristics required for your site.

In this article, we will look at how to change the domain of a WordPress site without losing its performance and position in search engine results. The whole procedure is quite simple and you need to follow a few simple steps:

  1. Use one of the methods described below to transfer the site to another domain.
  2. Set up robots.txt on the old and new domains.
  3. Create a 301 redirect from the old domain to the new one.

Moving a WordPress site to another domain

First way

The easiest way is to change the domain name in the admin console:

  1. Go to the admin panel, then go to the "Settings - General" page.
  2. In the existing fields “WordPress Address” and “Site Address”, fill in the new URL of your domain. We save the settings. Ready.

The method, although simple, is not suitable for everyone. If you have ever done by hand internal linking, then the above steps will not help in this case. Let's move on to the second method.

Second way

Again, this is far from an ideal method, and it is bad because it requires more labor than the third method (the most convenient, provided you have access to PhpMyAdmin). Okay, let's leave it at that for now:

  1. Open the SQL dump of the database in a text editor (eg Notepad++).
  2. Replace all occurrences of the old site address with the new one. Save the document.
  3. Import the dump into the database, before that, delete all existing tables there. Ready.

Third way

So we got to the most interesting and convenient way, which rescued the author more than once. Here we work directly with the database using SQL queries:

  1. Go to PhpMyAdmin, directly to the database. Click on “SQL” in the dashboard at the top.
  2. We enter three queries one by one or at once: UPDATE wp_options SET option_value = replace(option_value, "http://domain.ru", "http://newdomain.ru") WHERE option_name = "home" OR option_name = "siteurl"; UPDATE wp_posts SET guid = replace(guid, "http://domain.ru","http://newdomain.ru"); UPDATE wp_posts SET post_content = replace(post_content, "http://domain.ru", "http://newdomain.ru");
  3. We replace “domain.ru” and “newdomain.ru” with the old and new addresses, respectively. We save. In this way, we will achieve a change in the URL throughout the site, wherever it is. Ready.

Setting up robots.txt on the old and new domains

To successfully merge the old domain with the new one, you need to tell the search robot about the operation of a different site address. To do this, in the robots.txt file on the old domain, create the “Host” directive with the address of the new domain name (we do the same on the new one):

Host: newdomain.ru

This and the following procedures are necessary in order to maintain the “weight” of the site (TIC, age, etc.), and also to prevent the robot from thinking that it is dealing with a completely different resource, with the same content and duplicate pages.

I want to draw your attention to the fact that in the future a temporary drop in positions in search engines is possible, however, do not be alarmed, queries should recover over time.

Creating a 301 redirect

So that users and search robots, by contacting the old address (to the main or internal pages), automatically got to the new one, you need to create a 301 redirect (document moved) on the old domain. In the .htaccess file we write the following:

Rewrite Engine off Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://newdomain.ru/$1

Actually, that's the whole procedure.

There may be situations where you need to move WordPress to a different location on the same server or move it to a different server. In this case, you do not need to reinstall WordPress. WordPress is flexible enough to handle these situations.

Simple answer for most installations:

  • If the database and URL remain the same, you can move the blog by simply copying the files and database.
  • If the username or databases have changed, edit wp-config.php to match.
  • If you want to test the capabilities of the new server before full transition? you have to temporarily change the "siteurl" and "home" fields in the "wp_options" table of your new database (via phpMyAdmin or something similar).
    If you are using any kind of redirects (permalinks), you should disable .htaccess and reconfigure the permalinks so that they come alive.

Move WordPress within a site

Moving WordPress files from one location to another on your server - changing their URLs - requires some special steps.

Here is a step by step guide:

  1. Create a new location using one of these two possibilities:
    1. If you move your new folder- create a new folder.
    2. If you want to move WordPress to your root directory, make sure that all , and other files that can be replaced by copies have backups and/or moved, and then The root folder ready for new WordPress files.
  2. Log in to your blog.
  3. Go to panel > > .
  4. In field WordPress address (URI): change the address for your new WordPress core files location.
  5. In field Blog address (URI): change the address of your site to a new one.
  6. Click Update Options.
  7. (Don't try to open/view your blog right now!)
  8. For WordPress 2.0 only: Delete folder wp-content/cache.
  9. Move the main WordPress files to a new place. You must move both the files from the original directory, such as http://example.com/wordpress , and the files from its subdirectories.
  10. If you are using , go to panel > > and update your link structure in your file, which should be in the same directory as the main index.php file.
  11. If you're having problems with missing pictures that you've definitely uploaded, you'll need to change the picture paths in each post directly in the SQL database.

It is important that you set the URI location BEFORE you move the files.

Let's say you accidentally moved the files before you changed the URI. Let's assume that the files were originally stored in the /path/to/old/ folder and you moved them to the /path/to/new folder before you changed the URI. To fix the situation, create a symbolic link along the path /path/to/old/ (for Windows users "Symbolic link" is equivalent to a shortcut) to the folder /path/to/new/, i.e. give the command

Ln -s /path/to/new /path/to/old

and go through the steps in the normal way again. You can then remove the link if you wish.

Everything is ready. Test your site to make sure everything is working properly. If the changes included a new address for your blog, make sure people know the new address and consider adding some redirects to your .htaccess file to send users to the new address. If the change involves a new address for your blog, 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.

  • Note: If you are only changing the server while keeping the domain name, all you need to do is tweak wp-config.php and upload everything to the new server as it is.

If You Don't Care If Your Old Blog Works

  1. Download a copy of the main wordpress files from your OLD blog to your hard drive and edit wp-config.php to suit the new server.
  2. Again, download your database (but keep the old one just in case), 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!

If you want Your Old Blog To Still Work

Caution: Make sure you have a backup of your old blog's WordPress database before proceeding!

Part A - Activating Your New Blog

  1. Download your entire WordPress installation to your hard drive. Name the folder appropriately to indicate that this is your OLD blog's installation.
  2. Go back to your OLD blog and go to options and change the url (both of them) to that of your new site.
  3. Again, download your entire WordPress installation to your hard drive. Name the folder appropriately to indicate that this is your NEW blog's installation.
  4. Download your database once again (but keep the old one). Upload this database to your new server. It will be easiest if you use the same database name and you create a user with the same login credentials on your new server as on your old server.
  5. If you used a different database name and/or user (see previous step), edit wp-config.php in your NEW blog"s installation folder appropriately.
  6. Upload the NEW blog's installation folder to your new site. Presto, your NEW blog should be working!

Part B - Restoring Your Old Blog

  1. On the original server, delete your OLD blog"s database (remember, you should have a copy on your local computer that you made at the very beginning).
  2. Upload your OLD blog's installation folder to your original server, overwriting the files that are currently there (you may also delete the installation folder on the server and simply re-upload the OLD blog's files).
  3. Upload your OLD blog's database from your local computer to the server. That should do it!

Another procedure for making copies of posts, comments, pages, categories and custom field (post status, data, permalinks, ping status...) easy to follow:

  1. Install a new WordPress blog
  2. Go on old blog Admin panel. Here, in Manage > Export select "all" in menu Restrict Author.
  3. Click on Download Export File
  4. In new blog go on Manage > Import, choose Wordpress item.
  5. In the page that will be shown, select the file just exported. Click on Upload file and Import
  6. It will appear a page. In Assign Authors, assign the author to users that already exist or create new ones.
  7. Click on Submit
  8. At the end, click on Have fun

Note: using this method if there are some articles in new blog (like hello world, info page...), these will not be erased. Articles are only added. Using the former procedure the article in new blog will be deleted.

Moving WordPress to a New Server with Fantastico

Some webhosts use a service called Fantastico , which can install a vanilla WordPress web with just a few clicks. You can transfer your blog to one of these webs, but the steps are slightly different.

Begin by backing up your data. This includes backing up your WordPress database as well as all the core files, images, plugins, and other files on your site. See and for more details.

Make a copy of your database. You will need to edit the .sql file, and in case of errors, it is important that you work on a copy.

Begin the process of working from copies of your backups.

  1. If you have changed domain, edit the backed up database file to reflect this. A simple way to do this is:
    1. Using a , open a copy of the .sql database file.
    2. Using the search and replace function, find all instances of the blog"s old and replace it with the new URL.
    3. Repeat the process with your old email address. (For example, replacing [email protected] with [email protected])
    4. Save your changes.
  2. Upload your plugins and themes from your old site to the new one.
  3. Drop (delete) the database tables of the pre-installed Fantastico web.

When you are ready to check your site, make sure to and cookies so you will see the changes in your web browser.

Top Related Articles