How to connect a domain to your WordPress website using SSH and WP-CLI


In this articles we’ll show you how to easily connect a new domain to your WordPress website by using SSH and WP-CLI.

Even though shell access via SSH and WP-CLI, i.e. the WordPress command line, is mostly used by advanced users, this tutorial is also well suited to beginners without any prior knowledge. You will need about 5-10 minutes to connect your domain.


Before you start, the following requirements should be met:

Connecting the domain with your website’s directory

In this step you will adjust the usage type of your domain and connect this with your website’s directory in the 1&1 Control Panel.

  • Click on your domain and select the Edit usage type item there. For your domain select usage type: webspace.
  • Select your WordPress website’s directory at target folder and confirm with save.

Tip: You can find your website’s directory in the 1&1 App Center in the detail view of your website.

app-center-app-detailsConnecting WordPress with your new domain via SSH and WP-CLI

In this step you will adjust the your website’s database and save the new domain there.

cd clickandbuilds/my-wordpress-website
  • After arriving there, you can access WP-CLI, which is installed on our servers as a default. You can search the WordPress database with the wp search-replace command and replace the old domain with the new domain there. )
wp search-replace
  • Your WordPress website is now connected to the new domain.

Finally, we recommend that you adjust the settings for your old domain so that these are no longer displayed on your website. For this simply select an empty older or connect the domain with another website in the 1&1 Control Panel at Domains > Usage type.

If required: adjusting wp-config.php

If your website cannot be reached via the new domain after adjusting with WP-CLI, you will have to replace the old domain with the new domain in your website’s wp-config.php.

It’s that easy:

  • Connect your webspace with a FTP client such as FileZilla via SFTP.
    An overview of settings for FTP/FTPS/SFTP
  • Switch to your website’s directory (clickandbuilds/meine-wordpress-website) and open the wp-config.php file with a text editor.
  • Search for your old domain and replace this with your new domain.
  • Save the wp-config.php file and upload it to your webspace again.


You might also like

Please rate this post :

2 thoughts on “How to connect a domain to your WordPress website using SSH and WP-CLI

  1. Jervaiz says:

    How do I make my web address just
    How do I remove the temporary address?
    When I click connect domain it wont allow me the option of my own domain

    1. 1and1help says:

      Hi Jervaiz,

      can you please try it again? I tested it myself 2 minutes ago and was able to chose the domain after clicking on “Connect domain”. So maybe it was only something temporary.

      Best regards,
      Michael, 1&1

Leave a Reply to 1and1help Cancel reply

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