Skip to content
DATABASE PHP

How to change WordPress URL HTTP to HTTPS from database

A
Author
Jun 4, 2020 · 7 min read
How to change WordPress  URL HTTP to HTTPS  from database

In today’s online world, ensuring the security of your website is paramount. One of the most significant steps in securing your WordPress website is by enabling HTTPS (HyperText Transfer Protocol Secure) instead of the standard HTTP. HTTPS encrypts the communication between the browser and the server, which means all the data exchanged is securely transmitted. This is especially crucial for websites that handle sensitive information, such as user logins, forms, payments, and other personal data.

Migrating a website from HTTP to HTTPS not only improves security but also helps your website perform better in terms of SEO (Search Engine Optimization). Search engines like Google prioritize secure websites and reward them with a ranking boost. Furthermore, users are more likely to trust websites marked with a padlock icon in the browser’s address bar, signaling that their data is secure.

While switching your WordPress site from HTTP to HTTPS might seem like a complex task, it is actually a straightforward process that can be accomplished in various ways. One of the most effective methods is by directly modifying the WordPress database to reflect the new HTTPS URL. In this blog, we will explain step-by-step how you can change your WordPress URL from HTTP to HTTPS using the database.

Why Move from HTTP to HTTPS?

Before delving into the details of how to change your WordPress URL from HTTP to HTTPS in the database, let’s first discuss why this migration is essential.

1. Improved Security

When you switch from HTTP to HTTPS, data exchanged between the server and the browser is encrypted. This ensures that no sensitive data, such as passwords or credit card information, can be intercepted or tampered with during transmission. For WordPress sites, this is critical, especially for eCommerce websites and login pages.

2. SEO Benefits

Search engines like Google use HTTPS as a ranking signal. Websites that are secured with SSL certificates and use HTTPS generally get a small ranking boost compared to HTTP websites. In 2014, Google made HTTPS a ranking factor, and this has since become more important. Moving to HTTPS ensures your site is more discoverable and has better search engine visibility.

3. Trust and User Confidence

Browsers like Google Chrome display a “Not Secure” message in the address bar when users visit a site without HTTPS. This can make visitors uncomfortable and hesitant to interact with your site, especially if it requires login details or personal information. HTTPS builds trust with your users, who can see the padlock symbol next to the URL.

4. Compliance and Legal Requirements

Certain regulatory and legal frameworks require websites to handle data securely. If your site deals with personal user information, it may be required by law to use HTTPS. Websites using HTTPS are considered to be more compliant with data protection regulations, such as GDPR (General Data Protection Regulation) and PCI-DSS (Payment Card Industry Data Security Standard).

Prerequisites for Changing WordPress URL to HTTPS via Database

Before making any changes to the database, there are a few prerequisites you should ensure:

  1. SSL Certificate: Make sure that your SSL certificate is installed correctly on your WordPress website. You can get an SSL certificate from your web host, or you can use a free service like Let’s Encrypt. If you’re unsure whether your SSL certificate is properly installed, you can check by visiting your website with https:// (for example, https://www.yoursite.com), and your browser should display a secure padlock symbol in the address bar.
  2. Access to phpMyAdmin: To modify the database, you need access to phpMyAdmin, which is a database management tool provided by most web hosting providers. You can access phpMyAdmin through your hosting account’s cPanel.
  3. Backup Your Database: Backing up your WordPress database is crucial before making any changes. In case something goes wrong, you can easily restore your website to its previous state. You can use plugins like UpdraftPlus or perform a manual backup via phpMyAdmin.

Steps to Change WordPress URL from HTTP to HTTPS in the Database

Once you’ve ensured that the SSL certificate is installed and you’ve backed up your website, you can begin the process of changing your WordPress URL from HTTP to HTTPS in the database. There are two main methods for doing this: directly editing the database using SQL queries and using phpMyAdmin to make the necessary changes manually.

Step 1: Log into Your Hosting Account

The first step is to log into your hosting account. Typically, WordPress websites are hosted on platforms like cPanel, Plesk, or other hosting management systems. Once logged in, navigate to the phpMyAdmin tool. This tool allows you to interact with your WordPress database and make changes directly.

Step 2: Open phpMyAdmin and Select Your WordPress Database

After logging in to phpMyAdmin, you’ll see a list of all databases associated with your hosting account. Locate the database for your WordPress website, which is typically named something like wp_database or yoursite_db. Click on the database to open it.

Step 3: Edit the wp_options Table

In the left-hand menu, under your WordPress database, locate and click on the wp_options table. This table holds several key configuration options for your WordPress site, including the siteurl and home values, which define your website’s URL.

  1. Look for the siteurl and home rows. These are the values that define your website’s base URL and need to be updated to HTTPS.
  2. Click the Edit button (the pencil icon) next to each row, and you will be able to modify the option_value field.
  3. In the option_value field for both rows, change the http:// to https://. For example, change:http://yoursite.com to https://yoursite.com
  4. Once you’ve made the changes, click Go to save the changes.

Step 4: Update URLs in the Database

To fully switch your site to HTTPS, you need to update all internal references to your old HTTP URL throughout the WordPress database. These include URLs found in post content, media links, and other database tables. For this, you’ll need to run a series of SQL queries.

Here are the queries you should run in phpMyAdmin:

UPDATE wp_options SET option_value = replace(option_value, 'http://thecreativecoders.com', 'https://thecreativecoders.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://thecreativecoders.com','https://thecreativecoders.com');
UPDATE wp_posts SET guid = replace(guid, 'http://thecreativecoders.com','https://thecreativecoders.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://thecreativecoders.com','https://thecreativecoders.com');

UPDATE wp_posts SET pinged = REPLACE(pinged, 'http://thecreativecoders.com', 'https://thecreativecoders.com')WHERE pinged LIKE '%http://thecreativecoders.com%';

These queries will replace all instances of the HTTP URL with the new HTTPS URL across various tables in your WordPress database.

Step 5: Update URLs in Page Builders (Optional)

If you are using a page builder like WPBakery or Elementor, you may need to run additional queries to replace URLs embedded in page builder content.

For WPBakery, run these queries:


UPDATE wp_posts SET post_content = REPLACE(post_content, 'src="http://thecreativecoders.com', 'src="https://thecreativecoders.com')WHERE post_content LIKE '%src="http://thecreativecoders.com%';

UPDATE wp_posts SET post_content = REPLACE(post_content, "src='http://thecreativecoders.com", "src='https://thecreativecoders.com")WHERE post_content LIKE "%src='http://thecreativecoders.com%";

UPDATE wp_posts SET post_content = REPLACE(post_content, 'href="http://thecreativecoders.com', 'href="https://thecreativecoders.com')WHERE post_content LIKE '%href="http://thecreativecoders.com%';

UPDATE wp_posts SET post_content = REPLACE(post_content, "href='http://thecreativecoders.com", "href='https://thecreativecoders.com")WHERE post_content LIKE "%href='http://thecreativecoders.com%";


Step 6: Clear Cache and Verify Changes

Once you’ve made the necessary database changes, you should clear your website’s cache to ensure that visitors see the updated HTTPS URLs. If you are using a caching plugin, such as W3 Total Cache or WP Super Cache, clear the cache from within the plugin settings.

Additionally, clear your browser cache to ensure that you’re seeing the most recent version of your website.

Finally, verify that the changes were successful by visiting your website using HTTPS. Check if the site loads without any security warnings and confirm that all internal links now use HTTPS.

Conclusion

Changing your WordPress URL from HTTP to HTTPS is an essential step toward improving your website’s security, SEO, and user trust. While there are several methods to achieve this, updating the URLs in the database is a direct and effective approach. By following the steps outlined in this blog, you can safely and efficiently switch your WordPress website to HTTPS and ensure that your site operates securely and efficiently.

Remember to always back up your website before making changes, and if you encounter any issues, seek help from a professional developer or your hosting provider. With HTTPS in place, you’ll enjoy enhanced security and better search engine visibility.

A
Author

Author at The Creative Coders.

The monthly build log

One email a month. New posts, lessons, and the occasional strong opinion. No spam.