> ## Content Index
> Fetch the complete content index at: https://blog.esadax.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Block IPs from Accessing Your Website
- URL: https://blog.esadax.com/en/how-to-block-ips-from-accessing-your-website/
- Published: 2026-11-15T04:16:01.000Z
- Updated: 2026-11-15T04:16:01.000Z
- Author: Esadax 
- Tags: #tr-faq-03-how-to-how-to-block-ips-from-accessing-your-website, #en, #mdx-imported, FAQ

To block a specific IP address using Apache's `.htaccess` file, follow these steps:

1. **Open the `.htaccess` File**: Locate your `.htaccess` file in your web server's root directory.
2. **Block a Single IP Address**:
  - Replace `X.X.X.X` with the actual IP address you wish to block.
3. **Allow Access for a Specific IP Address**:
  - Replace `X.X.X.X` with the IP you want to allow.
4. **Country-wide Blocking**:
  - For blocking access from a specific country, use an online tool or service that generates appropriate CIDR notations for all subnets of that country. Copy and paste the generated directives into your `.htaccess` file.
5. **Apply Changes**: After making modifications, restart your Apache server to ensure the changes take effect.

To allow access only from a specific admin IP while denying others, use:

```apache
<RequireAll>
    Require all denied
    Require ip X.X.X.X
</RequireAll>

```

Add the following directives to the file under existing rules to block access from a specific IP address:

```apache
<RequireAll>
    Require all granted
    Require not ip X.X.X.X
</RequireAll>

```

**Example Configuration**:

To block `192.168.1.1`, add:

```apache
<RequireAll>
    Require all granted
    Require not ip 192.168.1.1
</RequireAll>

```

To allow only `192.168.2.3`:

```apache
<RequireAll>
    Require all denied
    Require ip 192.168.2.3
</RequireAll>

```