/    Sign up×
Community /Pin to ProfileBookmark

.htaccess to block IP’s

I need to block a number of IP’s from visiting my site. The range of IP’s I need to block are:
66.123.9.0 – 66.123.9.255
My .htaccess file currently looks like this:

[CODE]
Options None

<Limit GET POST>
order deny,allow
deny from 66.123.9.
allow from all
</Limit>
[/CODE]

It didn’t block any of those IP’s. Is there another way to block a range of IP’s?

to post a comment
Full-stack Developer

8 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayNov 28.2005 — That should have worked, but you can also specify a domain, i.e.

deny from microsoft.com
Copy linkTweet thisAlerts:
@Brad_ArmitageauthorNov 28.2005 — Actually, I think my mistake might have been putting that last decimal at the end instead of this:

deny from 66.123.9

Thanks for the reply TheBearMay, I'll try making that change and using the domain name aswell.
Copy linkTweet thisAlerts:
@Brad_ArmitageauthorNov 29.2005 — Ok, I tried:

[CODE]
Options None

<Limit GET POST>
order deny,allow
deny from 66.123.9.
deny from whatever.com
allow from all
</Limit>
[/CODE]


AND

[CODE]
Options None

<Limit GET POST>
order deny,allow
deny from 66.123.9
deny from whatever.com
allow from all
</Limit>
[/CODE]


As you see I even included the domain name as well, but it still won't block any of the IP's in the range ?

Any other ideas??
Copy linkTweet thisAlerts:
@bathurst_guyNov 29.2005 — Do you have rights to modify <limit> in a .htaccess file? Depends on whats in the http.conf file if you can or not - are you able to limit other things eg restrict valid-user.
Copy linkTweet thisAlerts:
@TheBearMayNov 29.2005 — Also may try removing the "allow from all" and see if that helps.
Copy linkTweet thisAlerts:
@Brad_ArmitageauthorNov 29.2005 — That didn't seem to do it either ?
Copy linkTweet thisAlerts:
@MstrBobNov 29.2005 — It's a silly syntax error. They happen to the best of us.

<i>
</i>&lt;Limit GET POST&gt;
order allow,deny
deny from 66.123.9.
allow from all
&lt;/Limit&gt;


The problem here was you had:

<Limit GET POST>

order [b]deny,allow[/b]

deny from 66.123.9.

allow from all

</Limit>

For what you want, you need [b]allow,deny[/b].

Hope that helps. ?
Copy linkTweet thisAlerts:
@CarolWDec 01.2005 — Speaking of denying access to an IP number, I have a few in my .htaccess file. But what happens to dial-up people? There are stilll lots of those, and I am one of them! So my IP number is dynamic, and every time I go offline and then return, I'm likely to have a different IP number. Then if I become an Unwelcome Visitor to somebody's site (haha), and I go offline, the next poor dial-up creature who gets the number I had previously is denied access, right? Poor thing! Just think of the mess I could make for somebody else!

I guess the big spammers tend to be on broadband, though, so their IP numbers wouldn't change very often - is that right? My guestbooks were hit by spammers, and finally I seem to be getting rid of them with .htaccess (what a relief).

Wed, 30 Nov 2005 20:39:40
×

Success!

Help @Brad_Armitage spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...