Migrácia WordPress webovej stránky

Sometimes you need to move a WordPress website to another server, and that’s why we bring you this proven safe procedure to keep the old website during the move and not break anything . An even simpler solution is offered by the modules written at the end.

Before you even start the migration, I would like to say a few words about the custom table prefix , which you can define in wp-config.php . It’s a good idea not to leave it at the predefined value “wp_”, but to choose your own prefix for each website (only numbers and lowercase letters!, e.g. mywebtest_) so that you don’t accidentally overwrite some existing data. Do you already have an existing database and would you like to change the prefix? Not a problem .

  1. Create a backup of all the tables in the database that your website uses. To export them, you can use the greatly expanded phpMyAdmin or my favorite Adminer (or the desktop applications HeidiSQL or Sequel Pro if you are on Mac OS X). By default, you get .sql as an output, but you can also choose a compressed format. Some web hosts have lower limits on the maximum size of the uploaded (imported) file and this can help you not to exceed the set quota.
  2. Backup the wp-content directory. It’s up to you whether you use your favorite FTP client ( WinSCP , FileZilla , Cyberduck …) or you also have access via SSH ( tar -pvczf wp-content.tar.gz wp-content/ ), which can be a much more elegant solution.
  3. Import the database to the new server. If you already have WordPress installed, you can easily use the aforementioned Adminer module.
  4. Upload the file searchreplacedb2.php ( WordPress (and others) Search and Replace Tool ) to the root directory of your website (where wp-config.php is also located). This tool is used to overwrite all occurrences of the old domain with the new one in your database. The reason why we use this script and do not simply rewrite the domain manually is its ability to work with serialized data as well. If you are concerned about the security of this procedure, you can perform it locally or on a test server rather than on the production site. You can skip this step and the next one if you don’t plan to change the domain.
  5. Let the address http://www.vasastranka.sk/searchreplacedb2.php be loaded. The script can automatically fetch the data you defined for the database in wp-config.php, if WordPress is already there. Press “Next”, select the tables you want to modify and define the old and new domains on the next page. Make sure you enter these URLs without the trailing slash! (correct = http://www.vasastranka.sk | incorrect = http://www.vasastranka.sk /). After replacing the old domain with a new one, do not forget to delete the file from the server.
  6. When uploading a brand new installation, just upload WordPress along with your own wp-content folder and set up wp-config.php as usual. If you already have a functional website there, continue with the steps below.
  7. Rename the wp-content folder to something else, like wp-content.new, and upload it to the same directory as the original wp-content .
  8. Open the wp-config.php file and find the line that starts with $table_prefix and comment it out. Create exactly the same line directly below it, just change the prefix of the tables to the one you defined. It will look something like this:
    // $table_prefix  = 'wp_';
    $table_prefix = 'mojwebtest_';

    Save.

  9. Rename the original wp-content to wp-content .old and the newly uploaded wp-content .new to wp-content .
  10. Check your website to make sure everything is working as it should. In case of some complication, you just comment the new prefix for the database tables and remove the comment on the original one in wp-config.php . Rename both wp-content folders back as they were and everything will go back to you as before.
  11. If there was no problem, log in to the control panel and Settings> Permalinks press “Save changes” twice in a row. This will ensure that your permalink structure and all page URLs work correctly for you. Then make sure you have in Settings> Privacy enabled content indexing by search services.

If you just want to change the domain or URL of the website and still use the same database and stay on the same server (move to a different directory), just do the following steps:

  1. Don’t forget a complete backup (files+database).
  2. Go to Settings> General and change the WordPress Address (URL) and Server Address (URL) to your desired new domain or location. Don’t forget to save these settings.
  3. (Do not try to reopen/reload your website or its administration now!)
  4. Move/copy all files (including .htaccess ) to the new location.
  5. Your website should be accessible now. The first thing you should do is go to Settings> Permalinks and press “Save changes” twice in a row.
  6. Existing multimedia (images…) will nevertheless still link to the old addresses. You can fix it using the Velvet Blues Update URLs module or find and replace them with the already mentioned tool .
  7. In Settings> Multimedia check the path to the upload folder. (Out of date since version 3.5.)
  8. If you’re using a custom currency and have an item that links to the home page, it will probably still contain the old value as well.
  9. In some cases, it is necessary to reset the file rights .

Other modules created to facilitate this process:

How do you do the migration? Do you use any other interesting tools and modules for migration? Share them with us below in the comments.

🤷‍♂️ Need help? Check out our services.

Leave a Comment

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

Own website for free
Scroll to Top