I've changed my wordpress default upload directory from:
mysite.com/files/year/month/upload
to
mysite.com/images/upload
I'm a bit stumped on the proper sql syntax to replace /files/year/month/
with /images/
.
Using phpmyadmin, I selected the correct db, selected the correct table, and searched/found what needs to be changed using this sql:
SELECT *
FROM `wp_postmeta`
WHERE `meta_value`
LIKE '%/files/%/%/%'
Now I need to REPLACE everything FROM wp_postmeta WHERE meta_value LIKE %/files/%/%/ WITH /images/
To modify the entries for the uploaded media files you need to run the queries found in this article: http://www.dezzain.com/wordpress-tutorials/how-to-move-wordpress-uploads-path-to-subdomain/
Mainly these two queries:
UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.domain.com/wp-content/uploads','http://img1.domain.com/uploads')
and:
UPDATE wp_posts SET guid = REPLACE(guid,'http://www.domain.com/wp-content/uploads','http://img1.domain.com/uploads')
The problem with the other answers is that although the upload path will be fixed for new files, the source path for media that has already been inserted into posts is still pointing to the old directory since the paths are stored in the database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With