We have multiple URL's in the database like:
http://www.example.com/_73737337/dir1/dir2/image.jpg
http://www.example.com/_892/direc/picture.png
http://www.example.com/_029929292929/dir/did/dic/dif/gallery.gif
All different length paths, different directories etc. What I need is to keep the file name at the end and replace everything before it with a new domain and directory.
For example:
http://www.example.com/_73737337/dir1/dir2/image.jpg
Will become:
http://www.newexample.com/images/image.jpg
AND
http://www.example.com/_029929292929/dir/did/dic/dif/gallery.gif
Will become:
http://www.newexample.com/images/gallery.gif
Is there any way to do this via a query to the database? There are around 3000 URLs to update.
These URLs sit inside content and not standalone entries in the database. So the query has to pick them out of the content field and ignore the rest of the content.
regexp_replace. If your version doesn't support that, you should write a script in PHP and update the content in a loop.