Title: Search &#038; Replace hack
Last modified: August 18, 2016

---

# Search & Replace hack

 *  [lunadust](https://wordpress.org/support/users/lunadust/)
 * (@lunadust)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/search-038-replace-hack/)
 * Hi I’ve been searching the Support Forum but don’t seem to be able to find a 
   hack to search and replace. Reason is my old links were absolute (i.e. [http://example.com/blog/1.jpg)](http://example.com/blog/1.jpg))
   but I replace all the old links with relative path links (i.e. 1.jpg). Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/search-038-replace-hack/#post-82990)
 * This would need you to run an sql query to do all the search/replace for you.
 *  [kristin](https://wordpress.org/support/users/kristin/)
 * (@kristin)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/search-038-replace-hack/#post-83111)
 * I had this problem when I moved my website from a subdomain to a top level domain.
   
   What I did was: Exported my database with phpMyAdmin (adding drop tables helps)
   Used find/replace in notepad to replace all of [http://sub.example.com](http://sub.example.com)
   to [http://www.newdomain.com](http://www.newdomain.com) Saved as a new file to
   keep my old database backed up just incase 🙂 Used phpMyAdmin to import the modified
   sql file
 *  Anonymous
 * [21 years, 6 months ago](https://wordpress.org/support/topic/search-038-replace-hack/#post-83447)
 * Is there anyone who can post the layout of such a query?
    I have on my site a
   lot of links to images on another server, since moving the site from a blogger-
   site hosted in a sub folder. example: http:/the_other_server.com/my_folder/img/
   image.jpg and I want those links to look like this: [http://my_new_domain.com/img/image.jpg](http://my_new_domain.com/img/image.jpg)
   I. e. I want to change all occurrences of: http:/theotherserver.com/myfolder/
   to: [http://my_new_domain.com/](http://my_new_domain.com/) or better yet, just
   to point to my site root. Thanks Nick
 *  [likoma](https://wordpress.org/support/users/likoma/)
 * (@likoma)
 * [21 years, 4 months ago](https://wordpress.org/support/topic/search-038-replace-hack/#post-83455)
 * Found this and it worked great:
 * [http://www.2020hindsight.org/2004/07/07/searching-and-replacing-within-phpmyadmin/](http://www.2020hindsight.org/2004/07/07/searching-and-replacing-within-phpmyadmin/)
 * It’s basically this code in PHP MyAdmin, click SQL:
 * `update 01_posts set post_content = REPLACE(post_content, "what I want to replace","
   the replacement text");`
 * I use numbers “01” instead of “wp” for my multiple installs, so make sure to 
   change that prefix to the tables in question.
 *  [glytch](https://wordpress.org/support/users/glytch/)
 * (@glytch)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/search-038-replace-hack/#post-83484)
 * thanks for that! I needed a way to change the url from some remote hosted images
   to some locally hosted and this did the trick.
    it’s a shame there isn’t a mass
   search and replace plugin , or more likey it’s a shame I couldn’t find it! but
   now I now how to run queries on myphp so not a bad result.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Search & Replace hack’ is closed to new replies.

 * 5 replies
 * 6 participants
 * Last reply from: [glytch](https://wordpress.org/support/users/glytch/)
 * Last activity: [20 years, 7 months ago](https://wordpress.org/support/topic/search-038-replace-hack/#post-83484)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
