Host Images Of WordPress Blog In Subdomain
- Updated On 17/04/2017
- Author : Pradeep Kumar
- Topic : Guides • WordPress
- Short URL : http://hbb.me/2ozelZb
CONNECT WITH HBB ON SOCIAL MEDIA
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 : 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.
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!
Want to discuss your queries and interact with experts? You can connect with HellBound Bloggers (HBB) Facebook group for free!
Join HellBound Bloggers (HBB) and get Instant Updates. We'll also notify you with Great Deals, Discounts and other Interesting Tips. We won't SPAM or SHARE your Email Address with anyone.
YOU CAN ALSO SEARCH FOR YOUR DESIRED TOPICS:
Thank you for reading! We welcome and appreciate your comments, but at the same time, make sure you are adding something valuable to this article. If you have any serious queries, suggestions or anything related to this article, feel free to share them, we really appreciate that.
But, if your blog comments are a random "Thank you", "Useful Post", or anything that doesn't actually upscale the article, then we'll be removing them and it won't be appeared below. Thanks for understanding and thanks for connecting with us. If you want to give us any feedback or report any errors, you can kindly contact us and we'll revert back soon.
- Facebook Comments
76 CommentsFacebook Comments