I have 2 Private Server and 1 Shared hosting. 1 of my private server is not much in use, but my shared hosting is getting overloaded with images running wordpress.

I want to set my own CDN with my private server. I have already done below things :-

  1. Create CDN subdomain of my site ( http://cdn.example.com with CNAME of my private server. )
  2. Added CDN subdomain to my Private Server ( http://cdn.example.com )

I need help in below two things :-

  1. Whenever image is uploaded , it instantly gets uploaded to my CDN server, that i have created in my VPS.
  2. All images starts loading from my CDN server like :- http://cdn.example.com/wp-content/uploads/2015/10/1.jpg

For 2, I think, There is option to use ".htaccess" , but I am too much worried about point 1, how to make wordpress upload my file to CDN instead of local folder.

Please do not comment and reply with , Use CDN company like maxcdn etc., I can't afford to pay 1 extra cent to CDN at the moment.

I need solution strictly based on my requirement above.

Any help would be highly appreciated.


  • I know you don't want CDN recommendations so forgive me, but you should just use Photon. Install WordPress Jetpack plugin, activate Photon. Totally free, takes 1 minute to setup Dec 20, 2015 at 6:23
  • It is already there, but , what i am trying to achieve is host image out of my shared hosting box.
    – John Cargo
    Dec 20, 2015 at 10:44

1 Answer 1


It sounds you want to do something similar as described in this article https://surpriseazwebservices.com/serve-images-from-sub-domain-in-wordpress/. You'll need to define your upload_url_path as your private server and also update the path of your existing images by running the following query in MySQL.

UPDATE wp_posts SET post_content = REPLACE (post_content,'http://yoursite.com/wp-content/uploads/','http://img.yoursite.com/'); 

The steps should all be documented in the link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.