Host Images Of WordPress Blog In Subdomain

Written by in Tutorials, WordPress - Print This Post



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.

Subdomain-images

It should be like this,

Store uploads in this folder : Images

Full URL path to files : http://img.yourdomain.com

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

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.

phpMyAdmin

Now put the following query in the box

UPDATE wp_posts SET guid = REPLACE(guid,’http://www.yourdomain.com/wp-content/uploads/’,'http://images.yourdomain.com/’)

Click on GO. This query is capable of replacing “http://www.yourdomain.com/wp-content/uploads/” with “http://img.yourdomain.com/” 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/(.*)$ http://images.yourdomain.com/$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!




HBB RSS
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic. You will also get instant access to 100+ HBB Guides & Tutorials.
If you wish to subscribe here via Email, then kindly click here.


Connect with HBB on Facebook Easily




Editor-in-Chief and Owner of 20 Years Old Kiddo, Open Source Enthusiast, Tech Blogger, Striving Entrepreneur, and a Typical Engineering Student. Addicted to Blogging, Walking and Messing. Catch him on Facebook, Twitter and .


HBB has 551+ Awesome Contributors. [Join HBB].

HellBound Bloggers (HBB) is a part of Slashsquare Network.







72 Responses to “Host Images Of WordPress Blog In Subdomain”

Leave a Reply


Comments Policy | Brand Your Comments | Do Follow Blog | Top Commentators Award


REFERENCE : 7 Tips To Be A Hero On Blog Commenting [HELPFUL]


Overall HellBound Bloggers (HBB) has 22,105 Genuine Comments and Yours Will Add More Value To It.




Previous Article:

Next Article:

  1. Ram kumar says:

    nice post :) buddy

  2. Nice tip. thanks a lot Pradeep.

  3. Suneel says:

    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?

  4. P.K.ARUN says:

    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.

  5. 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.. :D

      Improper ad placements? or SPAM clicks? :(

  6. Chandan says:

    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.

  7. Nice tutorial.Your blog is really loading faster than previous theme.This theme is really looking good and working well for you except comluv :)

  8. P.K.ARUN says:

    Hello pradeep please help me, after implementing this on my site (ashout.com) all my images are moved to sub domain (img.ashout.com) 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.

    • I checked your blog. Guess it is fine now.

      It’s working. Any issues from your side mate?

      • P.K.ARUN says:

        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!

  9. 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.

  10. TechChunks says:

    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?

  11. sidduz says:

    Nice post mate :) Thnx for share

  12. Tech Sputter says:

    Thats a very nice and useful info mate,keep up your good work :-) :-)

  13. gravman says:

    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.

  14. Wendy says:

    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?

  15. Suneel says:

    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.

  16. sureshpeters says:

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

  17. thanks for the awesome tutorial.

  18. Gokul says:

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

  19. cjschris says:

    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!

  20. Design Blog says:

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

    should i create and subdomain with wordpress install,
    or
    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 “

  21. thanh says:

    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 ?

  22. Jasmine says:

    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… :)

  23. 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.

  24. aswin says:

    EXCELLENT
    Do this create a problem while taking wordpress backup ?

  25. mayur says:

    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 ?

  26. Mayur says:

    currently my site is http://www.amigowork.com

    now i want to store images on my sub domains like..
    img1.amigowork.com
    img2.amigowork.com
    img3.amigowork.com

    Is it possible ?

  27. Mayur says:

    I am not using shared hosting & CDN.

  28. Mayur says:

    Full details of My hosting is here..

    http://jpss.in/webhosting.php
    ” Unlimited plan “

  29. Alyen says:

    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?

  30. 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???

  31. Klymene says:

    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?

  32. Kamal says:

    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 ?

    Kamal.

  33. Fren says:

    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.



Subscribe without commenting




COPYRIGHT © 2011 SLASHSQUARE NETWORK. REPRODUCTION WITHOUT EXPLICIT PERMISSION IS PROHIBITED. ALL RIGHTS RESERVED.

Slashsquare
Mobile Version · About Us · Contact Us · Subscription · Advertise · Review · Write For Us · Archives · Privacy Policy · Disclaimer
Loading...