Get the Official WPSaviour App Now!

BlogWordPress Security

How to Serve Images from a Sub-Domain [WordPress]

Everyone knows that Google began rating web site based mostly on Web page velocity. Although the distinction attributable to web page velocity might be as little as 1%, however it’s one of many a part of Google search engine optimisation suggestion. On this submit I’m going to share how one can host photos in a sub-domain and server photos to primary weblog.

Earlier I shared the best way to use dropbox as CDN, however utilizing Dropbox was a little bit handbook so I needed one thing automated which can additionally enhance my web site velocity. After looking the net, I discovered that serving photos from a sub-domain additionally improves the loading time due to the parallel downloading capacity of a browser. On this submit I’ll inform you the best way to serve photos from a sub-domain and in addition redirect the older ones to the brand new ones.

October 2016 replace: You must use MaxCDN or KeyCDN for serving photos from CDN below your web site sub-domain.

Creating A Sub-domain

Log in to your web-hosts CPanel, scroll down and search for sub-domains below domains and click on on it.

Enter a reputation for the sub-domain i.e img.instance.com, give the trail of the uploads folder which is normally public_html/wp-content/uploads and click on on create.

Setting a Sub-Area in WordPress

Utilizing a sub-domain is very easy. Go to Settings >> Media and enter the sub-domain within the Full URL path to information with http within the starting and no trailing slash (/) in the long run. Click on on save modifications. Look the picture for extra clarification.

You have got arrange sub area for WordPress photos however the older posts nonetheless use the entire URL. They are often modified to the sub-domain utilizing the next SQL question. First open phpMyAdmin.

 

Click on on SQL from the nav-bar and enter the question given beneath, then click on on Go. Be certain that to exchange instance.com along with your precise area.

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

Redirecting Outdated Photographs to the brand new one

Different pages on the Net and Serps might need listed your photos so it’s higher to redirect them to the brand new photos that are hosted on sub-domain. All you must do is enter the next code within the .htaccess file and put it aside. If .htaccess file isn’t accessible then create one.

RedirectMatch 301 ^/wp-content/uploads/(.*)$ http://img.instance.com/$1

Be certain that to exchange instance.com along with your precise area.

I hope this tutorial helped you in bettering you web page velocity. Do test your web site’s velocity utilizing these instruments and inform us about your new load time.

Download The WPSaviour App Now

Related posts
Beginner’s GuideBlogShowcase

7 Best Shopify Alternatives in 2020 (Cheaper and More Powerful)

Beginner’s GuideBest WordPress PluginsBlog

14 Best AI Chatbots Software for Your Website (Comparison)

Beginner’s GuideBlogTips

Magento vs WooCommerce – Which one is Better? (Comparison)

Beginner’s GuideBlogTips

12 Best Calculator Plugins for Your WordPress Site

Sign up for our Newsletter and
stay informed

Leave a Reply

Your email address will not be published.

Fear Of Missing Out?

Sign up with your email address to receive WordPress tips and updates
SUBSCRIBE NOW
Terms and Conditions apply
close-link
Click Me