Host Images Of WordPress Blog In Subdomain

Hosting images of your site in another subdomain is one of the best ways to improve the loading speed of your website. Last week, I spend some hours (or minutes) doing this.

If your pages contain more than one image then you should host those images in another domain. By this, the browser will be able to download those images in parallel with your main domain. It will reduce the concurrent connection.

WordPress does not support hosting images in different domain. But fortunately, it supports and allows you to host images in a subdomain. This article is about how to host your website post images in a subdomain along with the old images that were hosted in the main domain.

Create A Subdomain For Keeping The Images

To create a subdomain you need to use your domain control panel. The procedure for creating a subdomain depends on respective hosting provider; normally it is not a tedious task.

You can create your desired subdomain. But image or images or img recommended! 🙂 Create a folder with name “Images”.

Change The Default Image Uploads Folder In WordPress

Log-in to your WordPress dashboard. Now go to Settings | Miscellaneous. For WordPress 3.0.1, Go to Settings | Media.


It should be like this,

Store uploads in this folder : Images

Full URL path to files :

Click on Save Changes. From now onwards, whenever you upload images, it will be stored in the subdomain

Update The Old Images Location

Now you have updated the upload location of your post images, but what about the old post images? You can’t change the location of all the old images one by one. That’s a tedious task.

First download all the images in the folder /uploads/ and upload them into the folder Images.

Now we have to perform a simple SQL query on your database. You need to use your phpMyAdmin for executing this.

Go to phpMyAdmin and the click on the SQL tab.


Now put the following query in the box

UPDATE wp_posts SET guid = REPLACE(guid,’’,’’)

Click on GO. This query is capable of replacing “” with “” in all the images location URLs.

Hurray! Now you have completed the process almost 95%. Considering the images Google crawled and indexed, we have to redirect the old image URLs to new image URLs.

In order to do that, add the following line in your .htaccess file (What is .htaccess?)

P.S. Backup your .htaccess file before implementing.

RedirectMatch 301 ^/wp-content/uploads/(.*)$$1

Now you are done, perfect!

You can subscribe to our feeds to get quick updates about such tutorials!

Getting any error sort of thing? Do you know any other tip? You are welcome to share!

76 thoughts on “Host Images Of WordPress Blog In Subdomain”

  1. Yes this may improve your loading speed,but your server is still loaded even if try to fetch the images from subdomain !

  2. I decided to go back to the way it was and deleted the sub domain and changed the media settings to the way it was and now none of my images is loading. I can see them in the media section and on cpanel but when I load the site, no images is being loaded.

    Its all messed up. And my create new post is also messed up. I see that your entire post is a poor copy paste job from other sites who have written the article way before you did.

    You did not considered the other factors like wordpress updates and other plugin issues. No thought was given whatsoever. Its a word by word copy paste job.

    This is sad. Wasted several hours to find out and now will waste more hours to fix it.

  3. Its not working on wordpress version 3.5.1 Here some screenshots for various steps and settings. For phpmyadmin I tried two different codes both resulting in same results. Screenshots for both are here.

    I just uploaded the screenshots in my new sub-domain but it is not visible at

  4. Great tutorial and explanation.
    I just noticed why is it that your site is still hosting images on the main domain? Just asking, I hope you don't mind.

  5. Hello Pradeep,

    Hope all is well,

    I would like to know, if i use Next Gen Galleries, how could i change them to sub-domain ?


  6. Interesting!

    How would it work if I point my subdomain to the WordPress default uploads folder?

    What values would I need to provide in
    Store uploads in this folder :
    Full URL path to files :

    By the way, what's the difference between the 2 fields?

  7. Good tutorial, but my query is whether to use same webhost or use some CDN for hosting the images..

    P.S why haven't u implemented this in your blog???

  8. Hi I have already set all the tutorial but when I try to upload a new image will not upload the picture goes blank, that puevo be?

  9. Can i use more then one subdomain to store my images ?

    if yes.. then explain me how.. ?

    Which SQL queries i should use for it ?

  10. I’ve been looking to start a new site, but am having a difficulty getting my foot on the ground. Browsing other blogs, I’ve found that a site like Flickr has been known to delete images that’ve you stored on it- if you use it on your own site. Where do you think the best place to host images are? I don’t want to have them on my hard drive and take up the space, so typically I’d prefer an online site/server.

  11. This is a cool trick to host images in subdomain. So, is there a way to host images on another domain? … I know, put in the image URLs MANUALLY…

    Hehe… 🙂

  12. thanks ! but when i buy a new host and point it to images.domain! i got an error: you can upload your images – maybe y… something like that ! can any body help ?

  13. Thanks for information. one silly doubt, i usually create a subdomain for theme demo and script.

    should i create and subdomain with wordpress install,
    simply create a folder in the “/publichtml/img” -folder in using Filezilla in FTP ?? and change the media link in WP Dashboard.

    ” i dont want to take sudden risk in my blog “

  14. Can you please help.
    I get

    #1146 – Table ‘cj******_cj*****.wp_posts’ doesn’t exist

    P.s i put the *’s in just in case.
    Please Help!

  15. Hi, There is no option page like Miscellaneous under Settings option in WP 3.0 ,How to achieve the above in WP 3.0

  16. wow..never tried this things….will try out…i saw orkut also doing the same procedure..!! gr8 info

  17. Not working for me Pradeep. Checked it and tried it a couple of times. But I am missing something miniscule.

    I will try this later on again.

  18. I am a new blogger and followed the directions above. I didn’t need to move any old images since I am working on my first post.

    This may sound dumb, but where do I find the folder on FTP. There was the original Images folder. Shouldn’t there be a second one somewhere?

  19. A very helpful tutorial. However, I did find some mistakes…

    1) To change the upload path, in WordPress 3 at least, you have to go to Settings > Media. There is no Miscellaneous.

    2) Your sql query has the paths reversed. When I first tried it I got “0 rows affected”. When I changed the query to put the path being changed first, then it worked.

  20. Nice tutorial. But could you explain how exactly will it speed up your blog’s loading speed? After all, we are storing the images in the same domain name, right?

  21. This is a very nice and useful post for all blogs who like images in post, I have being thinking that I will not be using image in all my post again, but with is powerful tutorial, I think it is a good method to speed up your blog, if you are the type that like image in post as I do.

  22. Hello pradeep please help me, after implementing this on my site ( all my images are moved to sub domain ( and I also changed the images uploading path in wp dashboard (Miscellaneous Settings). Now when I try to upload images in new post it is uploading properly to correct path but it is not displaying in posts. When I check that images URL it is not showing images just giving 404 error means it is not uploading any images to the new path.
    Please help me pradeep.

      • Ya I changed all images address to new sub domain but the problem is, when I try to upload new images in post it is not uploading! Have u installed WP on sub-domian?

        • Not uploading in the sense bro? You get any error?

          Plz make sure the values in Miscellaneous are as follows :

          Store uploads in this folder : (The name of the folder you have created)

          Full URL path to files : (The subdomain you have created for storing the images)

          And I didn’t install WP on Subdomain!

  23. Hey brother you have changed your theme, the new theme also looking very nice. Yes that is one nice tips for increase our blog loading speed.

  24. That’s a real handy tip man. I never even thought about it yet…

    PS: I heard that you suffered an AdSense ban lately.. Is it true?

    • It’s quite simple and worthy bro!

      And yes buddy, my adsense account was banned by Google Inc. 🙁

      And I can’t able to get the correct reason from them.. still waiting.. 😀

      Improper ad placements? or SPAM clicks? 🙁

  25. I seen many of the bloggers uploading there images to subdomain for speed purpose, I’m also thinking to do so after seeing your post. Thanks for this post.

  26. Amazing Pradeep. This is surely going to be worked out by me. I had been plying around to reduce the loading time of my blog and I suppose this would help me.

    I realised that your blog’s loading time has come down drastically after you have changed the blog’s look and feel.

    Like your plain theme now. Looks like a news site. What’s the theme?


Leave a Comment