Tag Archives: MySQL

How to search for and replace escaped paths in a WordPress database

I recently migrated a website to the host WP Engine. Before the migration the site had WordPress installed in it’s own directory. The directory, in this case, was named wp.

WP Engine doesn’t allow this kind of directory setup, so I had to move all the WordPress files up to the root and then remove wp from all paths in WordPress’s MySQL database.

I used the PHP WordPress Search and Replace Tool to edit a copy of the database that I had imported to WP Engine.

Initially I did a search for the string mysite.com/wp and replaced all matches with mysite.com

Problem

This worked for everything except some escaped paths I found in the table created by the Slider Revolution plugin. The paths in this table looked like this:

{"image":"http:\/\/www.mysite.com\/wp\/wp-content\/uploads\/my-slider-image.jpg"}

Solution

To fix these escaped paths I had to search for the string mysite.com\\\/wp and replace all matches with mysite.com.