Getting Back Missing Images on My Websites After Enabling htaccess Hotlink Protection
Enabling hotlinking protection via cpanel or htaccess may not only protect your images from external sites but also from your other sites which you shared on the same host as well. This means you may find images which you yourself uploaded to your other sites missing.
This post was first & originally published at moralde.com.
I discovered this firsthand when I experimented with hotlinking protection a few weeks ago. All of my sites except this (my primary site) lost all their images.
I, at first, did not know it was due to the hotlinking protection but when I found out that all the sites’ htaccess files got modified at the same time that I enabled hotlinking protection, there’s no doubt about its cause. Each site sharing my hosting got their htaccess modified, except for the primary site’s.
Turns out the cPanel automatically created or modified the htaccess file in all sites sharing my hosting account. If you have your primary site called, say, ironmandomain.com, and you have other domain names sharing the same host, say -
- lunarpages, or your webhost actually sees all these as follows:
- ironmandomain.com (your primary domain)
Part of the htaccess entries generated, thus, would look like so:
Thus, all the above sites except for ironmandomain.com and the legitimate subdomain, i-am.ironmandomain.com, will experience missing images.
The actual URL which the browsers recognize as http://2tee.net, for instance, is not included in the list; so, it is seen as an external site and is denied hotlinking rights.
There are 2 obvious ways to remedy this glitch.
- Deactivate hotlinking protection
If you’re the kind who gives up immediately and think that hotlinking protection is more of a headache than a benefit, then just dramatically and with flourish say “To hell with hotlinking protection!”, and then disable it from your cpanel.
- Edit the htaccess files
Obviously, all you need to do is change the lines like
Sure enough, after I edited each site’s htaccess files right on the cpanel’s file manager, the sites images came back like nothing unusual happened to them.
One thing I noted when I checked the htaccess for each site is that they all have the same htaccess file content except that all wordpress sites has this at the beginning
while non wp sites just have
So, you shouldn’t panic the next time you find your images vanishing from your sites after you enabled hotlink protection in your sites now that you know how to bring the images back with a few tweaks in the htaccess file.
Like this post? Subscribe to my RSS feed and get loads more!