[Troubleshooting] Prevent Broken Images In WordPress After Turning Off CDN Service

by Rohit Khurana on March 22, 2013

Advertisement

If you run a WordPress Blog or website and have ever used or are using a CDN service, then it makes a lot of sense for you to read this through. If not, you may still read it for some general tips on redirection of sub-domains. Last year, I got an offer from a CDN service to try it for free. A CDN is a content delivery network which usually speeds up the website performance by hosting a copy of the images and other heavy files on their own network. It helps to improve the page loading time. I opted for it to try it for one of my website which is popular in India.

I used the service for around 2 months, but decided to not use it as the servers of the CDN service provider were not located in or near India from where most readers came, so it made no sense to use a CDN which does not speed up the website. But by then, I had published many articles with images and hotlinked those images from other article too. This caused a peculiar problem after I stopped using the CND service. The articles, where the images were hotlinked, had links of CND url like cdn.exmaple.com/image.jpg instead of my website example.com. So after I cancelled my account, the images stopped serving altogether!

Broken Image

I tried making it work with a rewrite rules in the .htaccess file and adding CNAME entries to the DNS Zone editor, but none of these method seem to work for me. After a series of hit-and-trial, I found out that I can create add-on domains in my hosting cpanel which can be easily redirected. So here is how the problem was resolved:

Advertisement

Step 1: Create a sub-domain

Create Sub-domain

Create a sub-domain with the same name as the CDN service, e.g. cdn.example.com

Create Subdomain

Step 2: Manage Re-Direct

Click on Manage re-direction

manage redirection

Step 3: Redirect sub-domain to domain

Redirect the cdn.example.com to exmple.com and save the rule.

redirect sub-domain to domain

This will start to resolve the cdn.exmaple.com images from the exmple.com domain and the broken images will get fixed.

If you like this article or this article helped you, you can +1 to recommend this article on google plus.

You can follow us on Twitter or join our Facebook Fan Page. If you have a question to ask us, submit your question at Answers By Trouble Fixers.

Looking for something else? Search here :

Leave a Comment

Previous post:

Next post:

© TroubleFixers – All about fixing computer troubles2007-2016 . All Rights Reserved.