{"id":2953,"date":"2020-03-31T15:56:26","date_gmt":"2020-03-31T15:56:26","guid":{"rendered":"https:\/\/chemicloud.com\/kb\/?post_type=ht_kb&#038;p=2953"},"modified":"2022-04-13T10:41:03","modified_gmt":"2022-04-13T10:41:03","slug":"enable-hotlink-protection-in-cpanel","status":"publish","type":"ht_kb","link":"https:\/\/chemicloud.com\/kb\/article\/enable-hotlink-protection-in-cpanel\/","title":{"rendered":"How to Enable HotLink Protection in cPanel and .htaccess"},"content":{"rendered":"<h2 id=\"what-is-hotlink-protection\">What is HotLink Protection?<\/h2>\n<p>A hotlink occurs when someone is directly linking content from your site to another site and uses your bandwidth to serve the files. For example, when someone is displaying an image hosted on your server on their own web pages. You can use this Hotlink protection security feature in cPanel in order to prevent this from happening.<\/p>\n<h2 id=\"enable-hotlink-protection\"><span id=\"how-to-enable-hotlink-protection-in-cpanel\">How to enable HotLink Protection in cPanel<\/span><\/h2>\n<p>This tutorial assumes that you are already <a href=\"https:\/\/chemicloud.com\/kb\/article\/how-to-login-cpanel\/\" target=\"_blank\" rel=\"noopener noreferrer\">logged into cPanel<\/a>.<\/p>\n<p>To enable hotlink protection in cPanel, follow the steps below:<\/p>\n<p>Once logged into cPanel, head up to <strong>Security &gt; Hotlink Protection<\/strong>.<\/p>\n<figure id=\"attachment_2956\" aria-describedby=\"caption-attachment-2956\" style=\"width: 783px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2956\" src=\"https:\/\/chemicloud.com\/kb\/wp-content\/uploads\/2020\/03\/Hotlink-protection-in-cPanel-1024x364.png\" alt=\"Hotlink protection in cPanel.png\" width=\"783\" height=\"278\" srcset=\"https:\/\/chemicloud.com\/kb\/wp-content\/uploads\/2020\/03\/Hotlink-protection-in-cPanel-1024x364.png 1024w, https:\/\/chemicloud.com\/kb\/wp-content\/uploads\/2020\/03\/Hotlink-protection-in-cPanel-300x107.png 300w, https:\/\/chemicloud.com\/kb\/wp-content\/uploads\/2020\/03\/Hotlink-protection-in-cPanel-768x273.png 768w, https:\/\/chemicloud.com\/kb\/wp-content\/uploads\/2020\/03\/Hotlink-protection-in-cPanel-50x18.png 50w, https:\/\/chemicloud.com\/kb\/wp-content\/uploads\/2020\/03\/Hotlink-protection-in-cPanel-1536x545.png 1536w, https:\/\/chemicloud.com\/kb\/wp-content\/uploads\/2020\/03\/Hotlink-protection-in-cPanel-60x21.png 60w, https:\/\/chemicloud.com\/kb\/wp-content\/uploads\/2020\/03\/Hotlink-protection-in-cPanel-100x36.png 100w, https:\/\/chemicloud.com\/kb\/wp-content\/uploads\/2020\/03\/Hotlink-protection-in-cPanel.png 1752w\" sizes=\"auto, (max-width: 783px) 100vw, 783px\" \/><figcaption id=\"caption-attachment-2956\" class=\"wp-caption-text\">cPanel &gt; Security &gt; Hotlink Protection<\/figcaption><\/figure>\n<ol>\n<li>Click\u00a0<strong><em>Enable<\/em><\/strong>. A new page will open that displays the\u00a0<em>Allowed referrers<\/em>\u00a0and\u00a0<em>Protected extension<\/em>\u00a0lists.<\/li>\n<li>Click\u00a0<strong><em>Go back<\/em><\/strong>.<\/li>\n<li>To allow specific sites to hotlink to your website, add their URLs in the <em>URLs to allow access<\/em>\u00a0menu.<\/li>\n<li>To block direct access to files of specific types, add those file extensions to the\u00a0<em>Block direct access for the following extensions<\/em>\u00a0text box.\n<ul>\n<li>For example, to block all\u00a0<code>.jpg<\/code>\u00a0images, add\u00a0<code>.jpg<\/code>\u00a0to the\u00a0<em>Block direct access for the following extensions<\/em>\u00a0text box.<\/li>\n<li>When you block these file types, others\u00a0<strong>cannot<\/strong>\u00a0hotlink those types of files from your website regardless of any other settings.<\/li>\n<\/ul>\n<\/li>\n<li>To allow visitors access to specific content through the URL, select the\u00a0<em>Allow direct requests<\/em>\u00a0checkbox.\n<ul>\n<li>For example, if you enable this option, a visitor could enter\u00a0<code>http:\/\/www.example.com\/folder\/example.jpg<\/code>\u00a0as a URL to access the\u00a0<code>example.jpg<\/code>\u00a0file.<\/li>\n<\/ul>\n<\/li>\n<li>To redirect requests for certain content, enter the URL to which you want to redirect your visitor in the\u00a0<em>Redirect the request to the following URL<\/em>\u00a0text box.<\/li>\n<li>Click\u00a0<strong><em>Submit<\/em><\/strong>.<\/li>\n<\/ol>\n<h2 id=\"how-to-disable-hotlink-protection-in-cpanel\">How to Disable hotlink protection in\u00a0cPanel<\/h2>\n<p>To disable hotlink protection, click\u00a0<strong><em>Disable<\/em><\/strong>.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-content\">\n    \t\t<div class=\"hts-messages hts-messages--alert   hts-messages--withicon \"   >\r\n    \t\t\t    \t\t\t    \t\t\t\t<p>\r\n    \t\t\t\t\tWhen you click\u00a0<em>Disable<\/em>, the system deletes the entries in the\u00a0<em>List the URLs to which you wish to allow access<\/em>\u00a0list. We\u00a0<strong>strongly<\/strong>\u00a0recommend that you save the list locally before you disable hotlink protection.    \t\t\t\t<\/p>\r\n    \t\t\t    \t\t\t\r\n    \t\t<\/div><!-- \/.ht-shortcodes-messages -->\r\n    \t\t\n<h2 id=\"enable-hotlink-protection\"><span id=\"how-to-enable-hotlink-protection-in-htaccess\">How to enable HotLink Protection in .htaccess<\/span><\/h2>\n<p>If you are not using cPanel on your server, you can still enable hotlink protection easily through the .htaccess file. You&#8217;ll just have to use the following code snippet.:<\/p>\n<div class=\"highlight highlight-source-apache-config\">\n<pre><span class=\"pl-c1\">RewriteEngine<\/span> on\r\n<span class=\"pl-c\"># Remove the following line if you want to block blank referrer too<\/span>\r\n<span class=\"pl-c1\">RewriteCond<\/span> <span class=\"pl-c1\">%{HTTP_REFERER}<\/span> <span class=\"pl-s\">!^$<\/span>\r\n\r\n<span class=\"pl-c1\">RewriteCond<\/span> <span class=\"pl-c1\">%{HTTP_REFERER}<\/span> <span class=\"pl-s\">!^https?:\/\/(.+\\.)?example.com<\/span> <span class=\"pl-sr\">[NC]<\/span>\r\n<span class=\"pl-c1\">RewriteRule<\/span> <span class=\"pl-sr\">\\.(jpg|jpeg|png|gif|bmp)$<\/span> <span class=\"pl-s\">-<\/span> <span class=\"pl-sr\">[NC,F,L]<\/span><\/pre>\n<\/div>\n<p>If you want to display a \u201cblocked\u201d image in place of the &#8220;hotlinked&#8221; image, replace the last rule with:<\/p>\n<pre>RewriteRule \\.(jpg|jpeg|png|gif|bmp) https:\/\/example.com\/blocked.png [R,L]<\/pre>\n<p>Now you know how how to enable or disable hotlink protection in cPanel or by .htaccess<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is HotLink Protection? A hotlink occurs when someone is directly linking content from your site to another site and uses your bandwidth to serve the files. For example, when someone is displaying an image hosted on your server on their own web pages. You can use this Hotlink protection&#8230;<\/p>\n","protected":false},"author":10,"featured_media":2956,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"ht-kb-category":[192],"ht-kb-tag":[],"class_list":["post-2953","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-website-security"],"_links":{"self":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/2953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/comments?post=2953"}],"version-history":[{"count":7,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/2953\/revisions"}],"predecessor-version":[{"id":4374,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb\/2953\/revisions\/4374"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/media\/2956"}],"wp:attachment":[{"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/media?parent=2953"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=2953"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/chemicloud.com\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=2953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}