How to change your WordPress site URL

Change WordPress’s address safely: in settings, in wp-config.php when you’re locked out, and in the database after moving domain or switching to HTTPS.

How-to guideIntermediate2 min readUpdated

WordPress stores its own address in two settings: WordPress Address (siteurl) and Site Address (home). Get them wrong and you can be redirected away from your own site.

Method 1: in settings

If you can log in: Settings → General, change both addresses, save.

Method 2: wp-config.php (when locked out)

  1. Open System Info & Files then File Manager and edit wp-config.php in the WordPress folder.
  2. Above the line /* That's all, stop editing! */, add:
define('WP_HOME', 'https://yourdomain.co.uk');
define('WP_SITEURL', 'https://yourdomain.co.uk');
  1. Save and reload the site.

These override the database values. Once you can log in, you can fix the settings and remove the lines, or leave them in place.

Method 3: phpMyAdmin

  1. Open phpMyAdmin and your WordPress database.
  2. Open wp_options.
  3. Edit the siteurl and home rows.

After changing domain or moving to HTTPS

Posts, image links and some plugin settings still contain the old address. Use a search-and-replace tool designed for WordPress, which correctly updates serialised data, to replace the old URL with the new one. A plain SQL REPLACE can corrupt serialised settings.

Take a backup first. How to back up WordPress

Choosing somewhere to host WordPress? Traxio’s WordPress hosting includes one-click installs, LiteSpeed caching and free SSL, with your first 30 days free.

Popular

Tip: press / to search from any pageSee all results