With Google getting picky about HTTPS on sites, I was hoping to be able to do a quick and easy SQL Query to search & replace anything http://
with https://
I normally do something like the below for moving hosts:
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
So I tried to do something like
UPDATE `wp_commentmeta` SET 'meta_value' = REPLACE(`meta_value`, 'http://', 'https://');
But it didn't seem to work. Anyway to do the ENTIRE database at once?
- I have tried a few options on S.O.F., but nothing worked well.
- I prefer not to have to install a plugin as a "fix"
If there is mySQL or htaccess script, I am more interested in those solutions.
Best Answer
If you have access to edit your
.htaccess
file, you can add the following into it: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 theguid
column (featured images) and thepost_content
column (backlinks etc). And then ofcourse also inside thepost_meta
table -meta_value
column andhome
/siteurl
inside youroptions
table. Here is the SQL Query that I normally use: