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!