Skip to main content

Restricting access to a website using the IP blocker in cPanel

Updated over a week ago

IP address access restriction is a useful feature to strengthen your website's security, prevent unauthorized access, or limit access to certain areas to specific users (office, developers, administrators, etc.).

This method allows you to, in particular:

  1. Block unwanted visitors

  2. Restrict access to a site or a folder

  3. Prevent repeated attacks coming from a specific IP

  4. Manage access without modifying the site's code

Prerequisites

  • Access to cPanel

  • Active hosting

  • Identify the IP address to allow or block

Task completion: 2 to 5 minutes

Expertise: beginner

How to do it?

Method 1 : Restrict access via the IP Blocker in cPanel (recommended)

This method is the simplest and does not require any manual file modifications.

Steps to follow:

  1. Log in to your cPanel

  2. In the Security section, click on IP Blocker

  3. In the designated field, enter:
    A full IP address (e.g. 192.168.1.10)
    Or an IP range (e.g. 192.168.0.1-192.168.0.40)

  4. Click Add

  5. The IP address is blocked immediately

The affected user will no longer be able to access your website.

Method 2 : Restrict access via the .htaccess file

This method is useful if you want to allow only certain IPs.

Steps to follow:

  1. Log in to your cPanel

  2. Open the File Manager

  3. Go to the site folder (usually public_html)

  4. Locate or create the .htaccess file

  5. Add the following lines:

    Order Deny,Allow 
    Deny from all
    Allow from 123.123.123.123
  6. Replace 123.123.123.123 with the allowed IP address

  7. Save the file

Important

⚠️ If you block all IPs except your own, make sure your IP address is correct, otherwise you risk losing access to your site.

⚠️ Changes made via .htaccess take effect immediately.

Références

Documentation cPanel – IP Blocker: <IP Blocker | cPanel & WHM Documentation >

Did this answer your question?