A domain is the address of your website and, at the same time, its unique identifier, which as humans we are able to remember quickly. However, it happens that the original choice of its name turns out to be wrong or for other reasons no longer suits us. We want to change it!
To do this, all you need to do is register a new domain and... well... you still need to change your WordPress domain somehow. That's what we're going to focus on today.
When it is necessary to change your WordPress domain
One example is already behind us. She got bored 🙂 But changing your domain name should be well thought out, planned and timely done. If you are just starting out, the website is in the works, then the topic is easy. It is a bit worse if the domain has already had its first months or even years of functioning and you suddenly think of changing its name.
By doing this, you are depriving your site of the power it has managed to develop over the time it has been running under its original address. The new domain will be starting this whole journey over again. If you still want to change the address, at least make sure you have 301 redirects from the old domain to the new one, to individual pages and articles. Inform Google in Google Search Console about the change. This is the only way the old name will pass on much of its power, but will it in 100%. If you do not make any mistakes it is likely, but in practice it happens differently.
Apart from the situation when you simply got bored with your domain name, you may want to change the address of your WordPress site if its development version is running on a temporary address, e.g. a subdomain, or locally on your computer. To move such a site to a production server, you will need to change the domain name.
A more dramatic situation is problems with Google. Someone has made mistakes on your website, which resulted in penalties imposed by Google. You work hard, but the website does not want to get into the TOP10. Sometimes in such situations, it is less expensive to change the domain name than to pay for a specialist who will try to fix the situation.
You will probably find many other reasons yourself why you might want to change your domain name. I once had a client who changed the address of his website because he only realised after a few months that there was a typo in it 🙂 Such situations, although surprising, also happen.
A few ways to change your WordPress domain
Changing your website address is not a complicated activity, but it may require you to do some things. The first is to change your domain name in your WordPress settings, and the second is to change your website address in the content where you link to media (images, videos, downloadable documents, etc.). Let's get started.
Changing the WordPress domain in its settings
All you need to do is go into your WordPress general settings, and you'll find a place to change your site's address.
Some difficulties may arise with such a change. When changing the domain name here, make sure that the new domain points to the place (server, folder) where the WP files are located. If this is not the case, you will have trouble logging into WP Panel after changing the domain.
In another situation where you are moving WordPress to a different folder that the new address points to, or to an external server altogether then first change the domain name in the WordPress settings and only then copy the files and database to the new location. This is not particularly convenient.
Change the page address by editing the wp-config.php file
If you are unable to use any other method, changing your domain name can be done by entering two lines in the wp-config.php file
define( 'WP_HOME', 'https://twoja-nowa-domena' ); define( 'WP_SITEURL', 'https://twoja-nowa-domena' );
This is not the way I recommend, nor is changing the page address using a child theme, where the functions.php these two lines can be added:
update_option( 'siteurl', 'https://twoja-nowa-domena' ); update_option( 'home', 'https://twoja-nowa-domena' );
Both of these cases are the kind of hard coding I suggest avoiding unless it's just a temporary measure to help you solve a specific problem.
How to change the siteurl in the database (phpMyAdmin)?
Changing the domain name in WordPress can also be carried out baseline directly in the database. To do this, you need to access it. The easiest way would be to run the database management application phpMyAdmin, which you probably have on your hosting account. On DiDHost you will find it by clicking on the WordPress section, and then at the installation for which you want to rename the domain you click on the "Database" tab, and then click on the link "open with phpMyAdmin"
You will see a list of tables in your site's database. Find the one called _options. Its prefix will probably be different from the one you see below in the screenshot.
Moving on, click edit next to the records which, as you can see, store the website address in their value. Changing the domain name in this case comes down to clicking on the edit link, leading the new name and clicking on the "Execute" button.
Remember to handle the database with care. Don't do anything if you are not sure what the consequences will be and make sure you make a backup copy of the database before making any changes. It's not about WordPress as a whole, it's about the base itself where you are about to change something.
Change of other links (URLs) in the database
The WordPress domain change is behind us, so why else write about link changes? Well, if your site is ready, there is content, and in the content e.g. images, file references etc... then the changes so far described in this article will not be sufficient. Inside the text there may be a photo, which is taken from the address using the old domain.
You can easily overlook this especially if your old domain and WordPress files still reside there. The graphics will load, but the moment you state "OK, I've moved everything, the site is working, I can remove the old domain and its content"... a problem will occur. Suddenly all the images will stop displaying. We have to do something about it.
Here, too, its several methods. Since we're in the database, let's stay there for a while longer. Go to the "SQL" tab and run the command as below:
UPDATE 320tH_posts SET post_content = replace(post_content, 'https://stara-domena','https://nowa-domena');
I have bolded three important elements. The first is the prefix, which will be different for you, so you should enter it as you have it in your WorsdPress database. Additionally, I've highlighted where you enter the URL of the old and new domain.
If you have checked that there is no error in the construction of the query click on the execute button and you should see in a moment how many changes have been made. It is very likely that this will definitely solve the problem with invisible images.
Changing links with the Better Search Replace plugin
If you find that changing the domain name as well as the links in the content with the above method did not work in 100%, or you are afraid of touching the database, you can try using a plugin called Better Search Replace.
With its help you will find all the old addresses in the WP database and change them to the new ones.
Changing links using Elementor
If you use Elementor on your site, it's worth taking advantage of its built-in tool for changing URLs. It works extremely simply:
Go to: Elementor > Tools and the Replace URL tab.
In one field you enter https://staradomena and in the second https://nowadomena validate, and as with SQL queries you get feedback on how many occurrences of the old name have been replaced by the new one 🙂
Let WordPress hosting do it for you
If you are a novice creator and owner of a site on WordPress, the above methods may be more or less complicated. You may even be reading this text and feel fearful about changing your website address.
Using WordPress hosting Changing the website address is a very simple operation.
- If you change the domain name on the hosting account where the WordPress instance is installed, the system will automatically make this change in the WordPress configuration as well. You don't have to do anything else 🙂 .
- If you have a development installation in a subdomain and you move it to a domain proper (you can use the copy and sync feature) then the domain renaming will be done by the hosting system automatically.
- If there's another scenario in your case, changing your WordPress domain can be done by running a feature that's designed for this purpose.
These are by far the easiest and fastest methods. Development let your hosting take care of you and actually take care of optimizing your uptime. If you don't have DiDHost WordPress HostingHighly recommended.
WordPress domain change. Seemingly an easy task, but more than once I have seen my students and clients get lost when it comes to making changes on a living organism. However, if you use the tips above, changing your website address won't be as scary as it's painted 🙂
I only caution you to make changes directly to the database. It is important to do them carefully, because if you have never worked directly with the database before, making a mistake can eat up unnecessary extra time you spend restoring data from a copy and trying to make changes again.
Use hosting tools, and if there are none, only then look for other avenues.
This WordPress release includes a security patch, and since we're talking about security, it's recommended that you update your sites immediately if your WordPress settings themselves have already
When you don't have the ability to restore your website/blog from a backup, there's a big problem you face. You are faced with the task of rebuilding
WordPress is a website management system which, thanks to its huge capabilities combined with its simplicity and scalability, has won the hearts of millions of designers and website owners on
Free information on JZS news
I invite you to become a subscriber! Thousands of readers already subscribe to news from JZS.
You can unsubscribe at any time. Your address is safe here.
Featured LifeTime Offers!
A set of great blocks for Gutenberg plus a library of ready-made templates.
Creating, managing and optimising Google, Facebook, TikTok or LinkedIn ads...
Text, audio and video chat. Increase sales through better interactions...