cPanel has two simple tools for unwanted traffic. IP Blocker denies chosen visitors access to your website, and Hotlink Protection stops other sites from displaying your images or files directly from your server. Both write rules to your .htaccess file, so they work immediately with Apache and LiteSpeed.
Before you start
- Access to cPanel.
- The IP address to block. Find it in cPanel → Metrics → Visitors or Raw Access logs, or check your own with the IP checker so you never block yourself.
Block an IP address with IP Blocker
- Open cPanel → Security → IP Blocker.
- In IP Address or Domain, enter one of these formats:
- Single IP:
203.0.113.25 - Range:
203.0.113.10-203.0.113.50 - CIDR:
203.0.113.0/24 - Implied range:
203.0.113. - Hostname:
bad.example.com(cPanel resolves it to an IP once)
- Single IP:
- Click Add.
Blocked visitors get a 403 Forbidden error on every site in the account. To unblock, find the entry under Currently-Blocked IP Addresses and click Delete.
Note: IP Blocker only covers websites. It does not block email, FTP or SSH. Attackers that change IP constantly are better handled by ModSecurity and the server firewall; contact support for persistent attacks.
Enable Hotlink Protection
- Open cPanel → Security → Hotlink Protection.
- Click Enable.
- Check URLs to allow access. Your own domains are listed; add any other site that may embed your files, such as a CDN hostname.
- In Block direct access for the following extensions, keep the image types (
jpg,jpeg,gif,png,bmp,webp) and add others you want to protect, for examplemp4,pdf. - Leave Allow direct requests ticked so people can still open a file by typing its URL.
- Optionally set Redirect the request to the following URL to a small placeholder image.
- Click Submit.
Check it works
- Open your site from a different network or phone: it should load normally.
- Embed one of your images on a test page on another domain: it should not display.
Troubleshooting
- You blocked yourself: log in to cPanel from another network or ask support to remove the rule; cPanel itself stays reachable.
- Images break after enabling hotlink protection: add every domain and subdomain you use, including
wwwand CDN hostnames, to the allow list. - Rules vanish: a plugin that rewrites
.htaccessmay have removed them; add them again.
