How to Change the URL of a Media File Uploaded in Wordpress

Asked 1 years ago, Updated 1 years ago, 93 views

I uploaded the wordpress image directly to the server a little while ago, but
I have decided to prepare a separate storage and upload the image to it.

So far, the URL of the image has been

http://hogehoge.com/wp-content/upload/wp-content/uploads/2014/04/image.jpg

It looks like this, but it's

http://hogehoge.s3.amazonaws.com/wp-content/upload/wp-content/uploads/2014/04/image.jpg

The domain name has changed to something like this.

However, the URL of the file before switching to storage is the older URL and is stored in the database.
I tried and tried to change the URL of the media file to the new domain name, but it didn't work.

If anyone knows how to change only the URL of the image uploaded by wordpress,
Thank you for your cooperation.

wordpress

2022-09-30 20:25

2 Answers

Am I correct in understanding that you would like to change the URL written in WordPress DB?

Search Replace DB is a good tool.
At first, I thought I should use SQL and replace it all at once, but in the case of WordPress, there is serialized data, and if I do this, it seems to be inconsistent.For more information, please visit our reference site.

The reference site is a short time ago, but the tool itself seems to be actively maintained and has been updated recently.

However, I have never used this tool before, so please use it at your own risk.The author of the tool also warns you to back up and do it at your own risk, as it is difficult to assume all cases.

Reference Site
http://www.infoscoop.org/blogjp/2014/08/14/use-search-and-replace-for-wordpress-when-moving/
http://webcre-archive.com/2012/10/04/wordpress-db-url-replace/

Tool site
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
https://github.com/interconnectit/Search-Replace-DB


2022-09-30 20:25

I wonder if the major method these days is to use?
In the WP-CLI, WordPress can be operated from the command line, and one of the commands is called "search-replace".
With this, you can replace the URL in bulk, so it is useful when you relocate the site.
Reference: http://gatespace.jp/2014/12/02/wp-cli-wp-search-replace/

WP-CLI is rich in official documents in English, so please take this opportunity to try it.
http://wp-cli.org/


2022-09-30 20:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.