Search and Replace of json arrays in the database – switching URL to HTTPS
-
On an E-Commerce site that I admin, we have moved the whole site to https. This has always been a straight forward thing to do except we ran into an issue today.
Two of the plugins in use store data in the DB as json arrays. Such data can contain URL’s (for images or anchors).
The string we need to change is in the form:
http\:\/\/example\.com
(note the forward slashes)
The problem: when executing an SQL query, you would need to escape some special characters with the \ escape character. When trying to do a search and replace of the above string, we get an error.
Since there is a move to json and many plugins thus store that data in the DB, how do we fix this? How do we search and replace
http\:\/\/example\.com
with
https\:\/\/example\.com
Note: We cannot just search and replace http with https as there are very many external links in posts and comments.
- The topic ‘Search and Replace of json arrays in the database – switching URL to HTTPS’ is closed to new replies.