Replace HTTP:// to HTTPS:// in WordPress Replace HTTP:// to HTTPS:// in WordPress wordpress wordpress

Replace HTTP:// to HTTPS:// in WordPress


If you have access to edit your .htaccess file, you can add the following into it:

RewriteEngine on# force SSLRewriteCond     %{SERVER_PORT} ^80$RewriteRule     ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

The code above will redirect with 301 (permanent), if don't want to use a 301 redirect, you can simply change the last section on the last line from [L,R=301] to [L,R].

If you want to be a little more thorough with your SQL replacement, you can usually find all the necessary links inside the posts table inside the guid column (featured images) and the post_content column (backlinks etc). And then ofcourse also inside the post_meta table - meta_value column and home/siteurl inside your options table. Here is the SQL Query that I normally use:

UPDATE wp_options SET option_value = replace(option_value, 'http://example.com', 'https://example.com') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE wp_posts SET guid = REPLACE (guid, 'http://example.com', 'https://example.com');UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://example.com', 'https://example.com');UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://example.com','https://example.com');


You can either try WP CLI or the Search Replace DB from Interconnect/it.

If you use the later, you can delete folder after replacing the URL.


You can try this free Wordpress plugin:https://wordpress.org/plugins/better-search-replace/

Also checkout this article for other ways:https://kinsta.com/knowledgebase/wordpress-search-and-replace/

Note that you should NOT replace GUIDs according to https://wordpress.org/support/article/changing-the-site-url/#important-guid-note:

the second part of that is that the GUID must never change. Even if you shift domains around, the post is still the same post, even in a new location. Feed readers being shifted to your new feeds when you change URLs should still know that they’ve read some of your posts before, and thus the GUID must remain unchanged.