β²οΈ Estimated reading time: 2 min
Enable Hotlink Protection prevents other websites from directly linking to your images, videos, and other media, which can save bandwidth and protect your content. Hereβs how you can enable it depending on your setup:
1. Enable Hotlink Protection via cPanel
If your hosting provider uses cPanel:
- Log in to cPanel.
- Navigate to Security > Hotlink Protection.
- Click Enable.
- Add your own domain(s) to the Allowed Referrers list.
- Specify which file types you want to protect (e.g.,
.jpg, .png, .gif
). - Optionally, redirect unauthorized requests to another URL.
- Click Submit to save changes.
2. Enable Hotlink via .htaccess (Apache Servers)
If your site runs on an Apache server, you can manually add protection using the .htaccess
file:
- Connect to your site via FTP or File Manager in cPanel.
- Open or create a
.htaccess
file in your websiteβs root directory. - Add the following code:
RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^https://(www\.)?yourdomain\.com/.*$ [NC] RewriteRule \.(jpg|jpeg|png|gif|webp|mp4|mp3)$ - [F,NC,L]
- Replace
yourdomain.com
with your actual domain. - Modify the file types as needed.
- This blocks direct image hotlinking while allowing requests from your own domain.
- Replace
3. Enable Hotlink via Cloudflare
If you use Cloudflare, follow these steps:
- Log in to your Cloudflare dashboard.
- Select your website.
- Go to Scrape Shield.
- Toggle on Hotlink Protection.
This will block external sites from embedding your images.

4. Enable Hotlink via Nginx
If your server runs Nginx, you can configure hotlink protection by editing your Nginx configuration file:
- Open the Nginx configuration file (e.g.,
/etc/nginx/nginx.conf
or your siteβs config in/etc/nginx/sites-available/
). - Add the following lines inside the
server {}
block:location ~* \.(gif|png|jpe?g|webp|mp4|mp3)$ { valid_referers none blocked yourdomain.com *.yourdomain.com; if ($invalid_referer) { return 403; } }
- Restart Nginx to apply changes:
sudo systemctl restart nginx
5. Enable Hotlink Protection via WordPress Plugin
If you prefer a plugin-based solution, you can install:
- All In One WP Security & Firewall (has hotlink protection settings)
- Prevent Direct Access β Protect WordPress Files
- WP Content Copy Protection & No Right Click
These plugins allow you to configure hotlinking protection without modifying server files.
Let me know which method you prefer or if you need help applying it to your specific setup! π
Only logged-in users can submit reports.
Discover more from HelpZone
Subscribe to get the latest posts sent to your email.