> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://wiki.volthosting.co.uk/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to Allow or Block a Specific IP Address for Your Website on cPanel

Sometimes, you want to block a specific IP address or restrict access to a part of your website to whitelisted IP addresses. Luckily, this is possible with the `.htaccess` file!

If you want to **block** a large range of IP addresses, we recommend using the cPanel `IP Blocker` by searching `IP Blocker` on cPanel.
![](https://storage.crisp.chat/users/helpdesk/website/a7f74f9f83d47000/74f3ezix0dq9pobj3k4vk06pxk8yym_1qx0egh.png)

You can also password-protect directories, [follow our guide here on this](https://wiki.volthosting.co.uk/en/article/how-to-password-protect-directories-on-cpanel-19lk72l/).

| This guide will work for Plesk website hosting following similar guidelines, but the screenshots are taken using cPanel as the website hosting panel.

1. Log into cPanel. If you're unsure, take a look at our [Logging In To cPanel](https://wiki.volthosting.co.uk/en/article/logging-in-to-cpanel-t631gj/) guide.

|| Looking for website hosting? Take a look at our [cPanel website hosting](https://volthosting.co.uk/cpanel.html)!

2. Once logged in, head to `Files`, and then `File Manager`.
![](https://storage.crisp.chat/users/helpdesk/website/a7f74f9f83d47000/6k7qlnktmwzkgvjr7pqylpnwvkbq0n_12s189n.png)

3. Navigate to the directory which you want to restrict access to.

4. Once you've in the correct directory, click `+ File` at the top of the page.
![](https://storage.crisp.chat/users/helpdesk/website/a7f74f9f83d47000/ynpy1q8tpj9zytb8yp9sftxcn87ok9_1byb17q.png)

5. In the file name box, type in `.htaccess`. Then click `Create New File`
![](https://storage.crisp.chat/users/helpdesk/website/a7f74f9f83d47000/gl0tx2aulqcgzur7siyamxac3mxnlo_ikeuch.png)

6. Once the file has been created, right click on it, and press `Edit`.
![](https://storage.crisp.chat/users/helpdesk/website/a7f74f9f83d47000/sktloz3nzbzuzlrkegetugqctjwmzq_5f3aii.png)

7. On the popup, click `Edit`.
![](https://storage.crisp.chat/users/helpdesk/website/a7f74f9f83d47000/yt6cefkxthezkr157nxurzfhuaenef_i4c311.png)

8. You'll see the file open, now we can put in the values we want!

## Denying IP addresses or ranges

To set rules for denying a specific IP address, you can use the template below:

```
Order Allow,Deny
Deny from 185.195.238.255
Allow from all
```
||| `185.195.238.255` and `185.195.238.254` are example IP addresses, please replace this with the IP address you want to block.

If you want to block additional addresses, you can add them as shown below:

```
Order Allow,Deny
Deny from 185.195.238.255
Deny from 185.195.238.254
Allow from all
```

If you want to block a whole range of IP addresses following CIDR notation, you can do so as shown below:

```
Order Allow,Deny 
Deny from 185.195.238.0/24
Allow from all
```

||| `185.195.238.0/24` is an example IP address range, please replace this with the IP address range you want to block.

You can also use wildcards for whole octets:

```
Order Allow,Deny 
Deny from 185.195.*.*
Allow from all
```

||| `185.195.*.*`  is an example range. Please replace this with your own.

## Allowing IP addresses or ranges

Allowing IP address ranges are very similar to denying them.

To set rules for allowing a specific IP address and denying anything else, you can use the template below:

```
Order Deny,Allow
Deny from all
Allow from 185.195.238.255
```

||| `185.195.238.255` and `185.195.238.254` are example IP addresses, please replace this with the IP address you want to allow.

If you want to allow additional addresses, you can add them as shown below:

```
Order Deny,Allow
Deny from all
Allow from 185.195.238.255
Allow from 185.195.238.254
```

If you want to allow a whole range of IP addresses following CIDR notation, you can do so as shown below:

```
Order Deny,Allow
Deny from all
Allow from 185.195.238.0/24
```

||| `185.195.238.0/24` is an example IP address range, please replace this with the IP address range you want to allow.

You can also use wildcards for whole octets:

```
Order Deny,Allow
Deny from all
Allow from 185.195.*.*
```

||| `185.195.*.*`  is an example range. Please replace this with your own.