Changing domain name in WordPress

During changing our domain,where we have wordpress to another we meet a problem with changing site url addresses and wordpress’s addresses which are assigned to actual installation. We will show a few ways to edit urls.

Method nr 1 – changing address in cockpit

The first method , that we want to show is changing address by WordPress admin panel.

Warning! This method we need to do before changing domain to antoher.

In first step we need to login to wp admin panel /wp-admin . In next step we need to go to general settings and find WordPress Adress (URL) and Site Address (URL) . In this fields we enter our new domain adress and aftter that clicking save changes. After doing that operation we will have a site error 404 because this domain is not added yet but the most important is that the links in our database will be corrected to links of our new domain.

Now after adding our site in cpanel Addon Domains and changing Document Root to new catalog we can enjoy our new site at the new address.

Method nr 2 – Changing links inside our database

Second method , that we want to show is changing adressess in database. That’s sounds complicated but operation is quite simple. In first step we need to find in cpanel option Phpmyadmin. In next step we need to find our database in left side of page and we clik on it. The list will expand and we need to find table _options . After clicking on the first lines we will see ,,siteurl,, and ,,home,, and in this fields we enter our new domain address.

Important!

After that change in wordpress admin panel we need to go
to Setting permalinks and click save changes to rebuild references

Method nr 3 – update_options


Next method , that we want to show is using fuction update_opions. Thanks to this fuction we have a pissibility to update/overwrite settings siteurl and home in database. To do this we need to go to file menager in cpanel and find a catalog where we have our site files and file functions.php (main catalog) . Now we need to right click on this file an choose edit . We need to add after line <?php this lines:

update_option(‘siteurl’,’http://customer-domain.eu’);

update_option(‘home’,’http://customer-domain.eu’);

Now save the file and refresh site. The link in database should be overwirited . After that operation we need to delete this to lines that we added.

If file functions.php isn’t exist we can create that file and add to it

<?php

update_option(‘siteurl’,’http://customer-domain.eu’);

update_option(‘home’,’http://customer-domain.eu’);

?>

After save and refresh our site we need to delete new file that we created a moment ago.

Method nr 4 -edit file wp-config

The last method , that we want to show is edit file wp-config. Like in previous method we need to find file wp-config in main catalog of our site and edit it.

We need to go to the last line of code and paste this:

define(‘WP_HOME’, ‘http://customer-domain.eu’);

define(‘WP_SITEURL’, ‘ http://customer-domain.eu’);

Warning! After this change ther will be no possibility to change address in admin panel (cockpit) of our site. These fields will be grayed out.

Tomasz

Leave a Reply