Home
/
WordPress
/
Configuration
/
How to configure WordPress to work with a new domain?

How to configure WordPress to work with a new domain?

There are few ways to change the domain name on your WordPress application:

  • Using the “Search & Replace” tool in Site Tools

Go to Site Tools  WordPress -> Search & Replace. Fill in the old domain in the field labeled Search String, then the new domain in the field named Replace String and initiate the task with the Search & Replace button.

  • From the WordPress admin Dashboard

Access your WordPress Dashboard (e.g. http://yourdomain.com/wp-admin) > Settings > General.

Under the WordPress address (URL) and the Site address (URL) fields enter the domain that you wish your application to work with and save the changes.

The same modification is valid if you want to add “www” to your domain.

  • Using phpMyAdmin

Change the siteurl and home options in your WordPress database. To do this, use the phpMyAdmin tool available in your Site Tools.

Once in phpMyAdmin, select your WordPress database and browse the table wp_options. Find the options siteurl and home and change their values to the new domain you want to use.

Make sure that you clear the cache of your browser and verify if your website is functional.

  • Using WP-CLI over SSH

Connect to your hosting server via SSH, navigate to your WordPress installation folder and execute the following commands:

wp db export

This command will create a backup of your database into an SQL file. After that execute:

wp search-replace ‘http://olddomain.com’ ‘http://newdomain.com’

The searchreplace command replaces all occurrences of http://olddomain.com with http://newdomain.com in the database of your application. Note that http://olddomain.com is the current domain configured on your WordPress and http://newdomain.com is the new domain that you wish to use.

wp cache flush

This is the last command that you should execute, so you can flush the object cache of your WordPress.

Share This Article