Install WordPress with new domain on the same sever


How to set up WordPress with a new domain on the same server?


Changing the domain in WordPress must be done both in the website settings and in all other data records (e.g. internal links). There are numerous plugins for this (e.g. WP Migrate DB) or manual solutions via DB Manager and wp-config.php.


This article is about changing the domain of a WordPress instance. If you want to set up additional WordPress instances on the same server, read our other articles.

You have a WordPress website that is currently accessible under an old domain ( and now it should be accessible on the same server under a new domain ( You can usually change the domain of your WordPress website relatively easily. I’ll show you different options here:

  • Domain change via plugin
  • Domain change via external script
  • Domain change via WP-CLI
  • Domain change manually

BACKUP! As before any system change, you should of course make sure that you have an up-to-date backup of your entire website!

Domain change via plugin

For most users, the plugin solution is probably the easiest and fastest way. There are numerous WordPress plugins for database editing that you can use here. I recommend using one of the following:

Both tools offer a “Search & Replace” mode that searches your entire database and replaces all matches accordingly. The only thing to keep in mind with this method is the correct use of the two strings.

On the one hand, you should think carefully about how specifically the find condition is chosen. If you only enter “”, it is possible that more will be changed than you want (e.g. if you wrote about your website in the text and the old name should remain in the old articles). Is the find text too specific, e.g. “” would not replace things where your e.g. only used http, no www or no trailing slash. A good average is “//”. Alternatively, you can of course run the process several times with different variants.

On the other hand, you absolutely have to make sure that the search and the replace string have exactly the same format. If you work with “http://” in the search, this must also be included in the replacement, otherwise it will inevitably lead to errors due to invalid URLs.

Domain change via external script

If you don’t want to install a plugin for a one-off change that can’t be uninstalled without a trace and you have no problem playing files on your server, interconnect’s search-and-replace script is recommended.

The tool is free and all you have to do is put a few files in your website’s folder on your server. Then you can easily call the script via the browser and run a search-and-replace process over your entire database. Of course, the same notes as for the plugin solution must be observed.

Domain change via WP-CLI

If you are familiar with SSH and command line programs, the WP-CLI is also a very elegant option. If you already have the WP-CLI installed, all you have to do is enter the following command:

php_cli wp-cli.phar search-replace

Domain change manually

All 3 methods don’t appeal to you? A domain change can of course also be done completely manually, but of course it also involves more risks. So I would only resort to this if the other methods really don’t work.

domain change

The first thing to do is to change the main domain. This is relatively easy and can be done in a number of ways:

In the WordPress backend: just go to Settings > General in the backend and change the domain in the WordPress address and Website address fields.

A domain can also be defined in wp-config.php (if this is not already the case). Simply make the following entries in the file:

define('WP_SITEURL', '');
define('WP_HOME', '');

The way using the RELOCATE function is a little less known but also good. To do this, set the entry “define(‘RELOCATE’, true);” in wp-config.php. then you call up the login via and then remove the relocate entry from the wp-config.php again.

Ultimately, the domain can also be changed directly in the database (e.g. via phpmyadmin). Simply adjust the “siteurl” and “home” entries in the “wp_options” table.

change database contents

The website should now be accessible under the new domain, but all internal links and possible settings from various plugins can still refer to your old domain and thus cause broken links or other errors. Without a proper search and replace tool, you now have to search all columns of all tables for the old domain in the database (again via pypmyadmin or similar) and then replace it. E.g:

update wp_posts set post_content =

Until you have made sure that you have caught all the entries, this is of course quite time-consuming.

Leave a Reply

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