leafleafDocy banner shape 01Docy banner shape 02Flower illustration

How to deny access to a single IP Address using .htaccess

Let’s assume that you wish to deny or block access to your website from 1.2.3.4 IP address.

The below lines provide the means to allow access to your website from all users except one with the IP Address: 1.2.3.4

# Order Allow, Deny

Deny from 1.2.3.4

Deny from 1.2.3.5
Allow from All

# Order Deny, Allow

Deny from 1.2.3.4

Deny from 1.2.3.5

If there are multiple IPs to which you want to deny access, simply add as many ‘Deny from’ rules as needed.

Share this Doc

How to deny access to a single IP Address using .htaccess

Or copy link

Table Of Contents