If you’re moving a WordPress in­stall­a­tion to a new domain or trans­fer­ring it to a different directory, you’ll need to update the WordPress URL. Below, we show you three easy ways to do this.

IONOS GPT
Your sovereign AI assistant for greater pro­ductiv­ity

Ask, create and research with the European al­tern­at­ive to ChatGPT. Robust security and unlimited chats give you peace of mind.

What’s the dif­fer­ence between a WordPress address and a website address?

WordPress uses two different URLs: the WordPress address and the website address:

  • The WordPress address is the URL where the WordPress in­stall­a­tion and core files are stored.
  • The website address is the URL visitors use to access the website.

In most standard in­stall­a­tions, both addresses are the same. However, they may differ if the WordPress files are stored in a sub­dir­ect­ory while the website remains ac­cess­ible through the main domain.

When should you change a WordPress URL?

Although it’s best to choose a URL that you can use long term, there are several situ­ations where you may need to change your WordPress URL. The most common reasons include:

  • You’re moving your WordPress website from a local server or test en­vir­on­ment to a live site.
  • You want to move the WordPress core files to a separate sub­dir­ect­ory while keeping the website ac­cess­ible via the main domain.
  • You’re carrying out a WordPress domain move.
  • You’ve obtained an SSL cer­ti­fic­ate and are switching your website to HTTPS.

If you’re moving a WordPress domain or switching your website to HTTPS, it’s important to set up redirects in WordPress so that visitors are auto­mat­ic­ally forwarded from old URLs to the new ones.

For a complete domain change, you should also update any old URL ref­er­ences stored in the database, including those in posts, pages, media paths and internal links. Plugins such as Better Search Replace or WP-CLI with wp search-replace can be used for this. Af­ter­wards, go to ‘Settings’ → ‘Permalinks’ and save the existing permalink structure again without making any changes. This refreshes the rewrite rules.

Finally, clear any existing caches, for example in your WordPress caching plugin, with your hosting provider or in the CDN, so that outdated content or redirects are no longer served.

How to change a WordPress URL

Below, we explain three different ways to change your WordPress URL.

Note

Before making any changes, create a backup of your database and WordPress files. If anything goes wrong, you can restore the previous version by uploading the original files to the server and importing the database backup. The quickest way to create a backup is to use a suitable WordPress backup plugin.

Changing the WordPress site URL in the admin dashboard

The most common and easiest way to change your WordPress URL is through the admin dashboard. Go to ‘Settings’ → ‘General’. Here, you’ll find the fields for changing the WordPress address and the website address.

Image: General settings in the WordPress admin area
In the WordPress dashboard, you can change the WordPress URL under ‘Settings’ → ‘General’.

In most cases, both URLs are identical. If you want to move the WordPress in­stall­a­tion to a different directory while keeping the website ac­cess­ible at the same address, you only need to change the WordPress address. Once you click ‘Save’, the dashboard will be ac­cess­ible under the new URL.

If you make a typo in the new URL and can no longer access the dashboard, you can correct the WordPress URL via the wp-config.php file.

Using wp-config.php to change WordPress URL

A second way to change your WordPress URL is via the wp-config.php file, located in the root directory of your WordPress in­stall­a­tion. The easiest way to access this file is with an FTP client such as FileZilla. You can then edit the file using a text editor.

To change the WordPress URL, add the following code before the line /* That's all, stop editing! Happy publishing. */:

define('WP_HOME', 'https://www.new-domain.com');
define('WP_SITEURL', 'https://www.new-domain.com');
php

If you define WP_HOME and WP_SITEURL in the wp-config.php file, these values override the settings in the WordPress dashboard. This is par­tic­u­larly useful if you entered an incorrect URL and can no longer access the dashboard. The cor­res­pond­ing URL fields will be greyed out and cannot be edited there. To make further changes, update the values directly in wp-config.php.

Image: Greyed-out fields for changing the WordPress URL in the dashboard
If the lines of code are stored in the wp-config.php file, editing in the WordPress dashboard is disabled.
Note

Important: The URL you enter must not end with a trailing slash (/).

Changing WordPress URL in the database

The third way to change your WordPress URL is directly in the database. To do this, log in to phpMy­Ad­min through your hosting provider. In the WordPress database, the relevant URL entries are stored in the wp_options table (the wp_ prefix may differ) under siteurl and home.

Click the current value in the option_value column for the relevant row (siteurl or home). An input field will open where you can enter the new URL.

Reviewers

Go to Main Menu