0

I am working on website and trying to use cdn filepath for all media files. I already copied media library files into s3 bucket and they work good. Problem is, I tried to update database by using

update wp_posts set post_content = REPLACE(post_content, 'http://example.com/wp-content/uploads', 'http://s3.amazonaws-mywebsitelink.com/wp-content/uploads');

it did not change anything.

I want that my website should display the media files from that Amazon s3 bucket link.

For example;

http://mywebsite/wp-content/uploads/2022/06/2568.png But I want Wordpress to read this attachment from http://s3.amazonaws-mywebsitelink.com/wp-content/uploads/2022/06/2568.png

These urls are not real.

Then i tried to use

define('WP_CONTENT_URL', 'http://s3.amazonaws-mywebsitelink.com/wp-content/uploads');

then all the image files are broken for website. I rolled it back. How can i do this change?

I also thought of using this solution but this way HTML page will load all images twice first for local images and then CDN images. That is not what i wanted.

Edit about new uploads: When i upload a new file, it automatically gets the s3 url and works. But even if i got premium and activated the rewrite option for Offload Media Lite plugin for s3, they still stays like local urls of my wordpress. So my problem is with previous images. I have to change them manually, i think.

Please help, thanks.

utkuyceng
  • 43
  • 6
  • When you use `define('WP_CONTENT_URL', 'http://s3.amazonaws-mywebsitelink.com/wp-content/uploads');` -- And your images are broken .. View source, and check to see if the URL is valid inside the page source. You can also view your console to see if there are broken links and track it down that way. Also if you are defining `WP_CONTENT_URL` and your base website is SSL (https) make sure the cdn URL is also `https` – Zak Jun 14 '22 at 21:15
  • It also goes without saying .. Check your CDN by trying to hit the image URL directly and be sure you can see them directly. – Zak Jun 14 '22 at 21:17
  • @Zak yes i can see images directly when i change path at url bar. So images are exist and working. And i am also using https, just checked it. When i upload a new file, it automatically gets the s3 url and works but even if i got premium and activated the rewrite option for Offload Media Lite plugin for s3, they still stays like local urls of my wordpress. – utkuyceng Jun 14 '22 at 21:27

0 Answers0