Nov
9
2018

Updating your WordPress site URL to HTTPS in the database

If you’re a WordPress developer, you’ve probably had the need to update an old website’s URL to use HTTPS recently.

This guide will help you to change your WordPress website’s settings to accommodate the move to HTTPS for your website, including the options in the database and all mentions of your website’s HTTP domain within your existing website’s content.

You’ll need database access to complete these tasks fully please back up your website and database before making any changes (or, even better – use a test version of your website!).

Before following these guides, you’ll need to install an SSL certificate for your domain. LetsEncrypt.org offers free SSL certificates which can renew automatically, depending on your website hosting company’s settings.

Why update your WordPress website to use HTTPs?

If you’ve been running a website for a few years, you may have your website accessible via HTTP – this is a simple protocol which means web traffic between a website visitor and your server isn’t encrypted. Potentially, this means that anyone could, with the right knowledge, intercept this traffic for malicious purposes.

Using HTTPS for access to your website enhances its security by encrypting the traffic between the website’s server and your visitors.

Search engines, such as Google, have recommended for some time now that all websites use HTTPS to provide content to visitorsChrome browser even flags your site with an error message if it doesn’t use HTTPS now.

How to change your WordPress site’s siteurl and homeurl settings in the database

  1. Back up your WordPress website and database before attempting these changes!
  2. To change your WordPress website’s basic URL settings to use HTTPS rather than HTTP, the first step after installing your SSL certificate is to log in to your database management tool (such as phpMyAdmin, used in this tutorial).
  3. Navigate to the options database table. This may be called just options, or something like wp_options, or something_options (if you’re really stuck, look in your WordPress website’s wp-config.php file and see if the database prefix setting is set here using the $table_prefix.
  4. Updating the siteurl setting in your WordPress website database
    Locate the siteurl and homeurl settings
    in this database table. You’ll see they are set to something like http://www.yourwebsite.com – see image above.
  5. Change the values of these settings to https://www.yourwebsite.com. Don’t forget to update the table with your changes.

How to change your WordPress website URL in content

If you’ve done that in WordPress’ wp_options database table for the siteurl and homeurl settings, that won’t be enough to tie off your change to HTTPS entirely – as your existing WordPress pages and posts will still link to other pages and images using your HTTP domain. Follow these steps to update your website URLs in WordPress’ content as well, via the database:

  1. Back up your WordPress website and database before attempting these changes!
  2. Log in to the database tool you use (this guide uses the popular phpMyAdmin application).
  3. Navigate to the wp_posts table (the name of this table may vary depending on your database prefix – please see notes above).
  4. Click the SQL tab to run SQL queries on the database.
  5. Run this SQL query, replacing www.yourwebsite.com with your own website’s domain name. Be sure that wp_posts is the name of your WordPress posts table:
    update wp_posts set post_content = replace(post_content,'http://www.yourwebsite.com','https://www.yourwebsite.com');
    Change your website domain to HTTPS in WordPress content database

Of course, if you’re stuck and would like our help to install your SSL certificate to your WordPress website’s domain and do all of the tidy up we suggest above, get in touch with our WordPress development experts.