How to fix Mixed Content and Converting to HTTPS without Plugins After Migration from Local to a Live Website

Some people skip setting up SSL on their local WordPress sites to avoid any potential hassles. But when they move that site to a live server, they run into issues with mixed content since the live site needs HTTPS.

You could use a plugin like Really Simple SSL to fix things up (it works great, by the way), but having to rely on yet another plugin can be annoying.

So I put together this guide on how to fix the mixed content problem and switch to HTTPS without using any extra plugins after migrating from local to live. The guide is using Ubuntu 22.04 and Open Litespeed, but the same principles should apply to all environments. Hopefully you’ll find it useful!

Feel free to point out any mistakes or share extra tips. Thanks!

Before Starting:

  • It’s very important to back up your Local site database and files before doing any changes.
  • Ensure your live site’s SSL certificate is correctly installed and active.

Step 1: Update WordPress Site URLs in Database:

  • Connect to your Local site’s database using phpMyAdmin, MySQL Workbench, or a similar tool.
  • Find the wp_options table.
  • Update the siteurl and home values to your live site’s HTTPS URL:

UPDATE wp_options SET option_value = REPLACE(option_value, ‘http://localhost’, ‘’) WHERE option_name IN (‘siteurl’, ‘home’);

Replace “” with your live site’s domain.

  • Admin Console:
    • Log in to your Local site’s WordPress admin.
    • Go to “Settings” > “General”.
    • Update “WordPress Address (URL)” and “Site Address (URL)” to your live site’s HTTPS URL.
    • Click “Save Changes”.

Step 2: Update Internal Links and URLs:

  • Use the command-line tool “wp search-replace”:

wp search-replace ‘http://localhost’ ‘’ --all-tables --precise

Replace “” with your live site’s domain.

Explanation of the code:

  • –all-tables: Replaces in all tables.
  • –precise: Ensures accurate replacements.

Step 3: Update Media URLs:

To update media URLs without using a plugin on your Ubuntu 22.04 server, you can utilize command-line tools like sed or find combined with grep to search and replace URLs recursively within your uploads directory and its subdirectories. Here’s how you can do it:

  • Access Your Server:
    • SSH into your Ubuntu server where your WordPress site is hosted.
  • Navigate to Your Uploads Directory:
    • Use the cd command to navigate to your website. Here is an example of the command:

cd /home/

Replace “” with your live site’s domain. From there navigate to your website’s WordPress uploads directory. Typically, it’s located at


s. Here is an example of the full path:

cd /path/to/your/wordpress/installation/wp-content/uploads

  • Use grep and sed to Update URLs:
    • Run the following command to recursively search for instances of http://localhost within your uploads directory and replace them with your live site’s HTTPS URL:

grep -rl ‘http://localhost’ . | xargs sed -i ‘s|http://localhost||g’

  • Replace with your live site’s HTTPS URL.
    • This command searches recursively (-r) for files containing http://localhost within the current directory (.) and its subdirectories. Then, it pipes (|) the results to sed to perform the search and replace operation.
  • Verify Changes:
    • After running the command, verify that URLs have been updated correctly by checking a few random files in your uploads directory.

Step 4: Update .htaccess File

  • Open the .htaccess file in the root directory of your WordPress installation.
  • Add the following lines at the beginning of the file to force HTTPS:


RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Step 5: Test and Fix Redirects:

  • Check your live site thoroughly for broken links, mixed content warnings, and incorrect media loading.
  • If necessary, set up redirects from old URLs to their new HTTPS counterparts using your web server’s configuration.