BlogWordPress Security

How to Redirect WordPress Images to Sub-Domain for Faster Loading

Redirect WordPress Images to Sub-Domain for Faster Loading

Everyone knows, loading of a web site issues quite a bit for excellent user-experience, and for search engine rating. There are lots of CDN community (MAXCDN, Cloudflare), which can allow you to setup content material supply community, and velocity up loading time of your web site. Although, we are able to’t obtain CDN like function, with our personal internet hosting, however we are able to velocity up our weblog by loading photographs from sub-domain. You may also use sub-domain to server static recordsdata (CSS, JS) and different recordsdata.

  • What’s CDN (Content material supply community)

Through the use of your sub-domain for serving photographs, you’re enabling parallel obtain. This can assist in bettering web page efficiency, and loading time. Many excessive visitors web sites are utilizing CDN or sub-domain to divide the load from principal area. For different suggestions to enhance web page efficiency, you may learn this helpful information from Sixrevisions.

  • Learn: Sub-domain or sub-directory for WordPress addon blogs

In self hosted WordPress web sites, the uploaded photographs and media recordsdata are saved to the /wp-content/uploads folder location. Anybody, can add a sub-domain like (specified for picture importing right here), and factors it to the /wp-content/uploads folder of Thus the brand new picture url can be modified from to

When you add this sub-domain instantly after putting in your web site then this is superb. However 99.99% bloggers hardly have a data of this sort of web-development on the preliminary days of running a blog. So when you have already created plenty of posts with photographs, and got here to find out about serving photographs from a sub-domain, you must redirect the earlier URL’s (i.e. to the brand new sub-domain URL’s. In any other case search engine treats your picture url as a reproduction one. So you must modify .htaccess file by including a easy 301 redirect code.

  • To begin with learn add subdomain to serve photographs for a WordPress Weblog.

Typically including the next code to .htaccess file can redirect the weblog’s url to the brand new sub-domain.

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

However when ^/wp-content/uploads/ is used for 301 redirection then it redirects all of the /wp-content/uploads/ folders to As the principle .htaccess i.e. underneath public_html listing controls all of the redirection of a principal root listing . So it additionally redirect’s the picture url’s of add-on area primarily based web sites as a result of there are additionally /wp-content/uploads/ folder obtainable for Thus photographs won’t be displayed for the add-on area web sites. So you may’t use the above talked about 301 redirection for you principal area because it impacts the add-on domains. You shoud edit .htaccess file in such a means for 301 redirection in order that it solely redirects /wp-content/uploads/ folders of a particular area solely bypassing the opposite sub-domains or add-on domains.

This sorts of redirect known as wild-card redirect. Their are two strategies can be found for making such wild-card 301 everlasting redirect.

  • Utilizing Redirect Choice Out of your host Management-panel   or
  • Edit .htaccess file manually

Web page Contents

Use Redirect Choice Of Your Web site’s Management Panel

Some common internet hosting firms (Hostgator, Bluehost) presents redirect choice underneath cPanel, in order that one can simply redirect any hyperlink with out having a minimal data of coding.

Simply navigate to “Domains” part of your web-hosting management panel and open ‘Redirects’ choice.

cPanel redirection

Now underneath “Add Redirect” part fill the shape as seen within the under determine:

Wild card redirection

Don’t overlook to tick the Wild Card Redirect Choice. In any other case all of the /wp-content/uploads/ folder underneath the principle listing shall be redirect to and thus it would present damaged photographs. Nevertheless ‘Redirect’ choice will not be at all times obtainable for each web-hosting. So as to handbook wild card 301 redirect it is best to add some code to the .htaccess file of the web site’s root listing.

Serving photographs from Sub-domain utilizing .htaccess :

Of all the tactic, I desire utilizing .htaccess for redirection. If you’re new to .htaccess file, listed here are two assets that can assist you out:

  • How you can create WordPress .htaccess file
  • How you can edit WordPress .htaccess file

Open the file supervisor out of your management panel and navigate to /public_html/.htaccess folder.

Proper click on it and press ‘Edit’ choice.

Serve images from Sub-domain

Paste the next code to the .htaccess and reserve it:

RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^wp-content/uploads/?(.*)$ "$1" [R=301,L]

Be aware: change all “yoursite” phrase with your personal area identify the place you must apply the code.

Download The WPSaviour App Now

Leave a Reply

Your email address will not be published.

Pay in your preferred currency
Indian rupee