Overclock.net banner

How do I ban an IP from accessing my apache server?

782 10
Someone has been spam downloading from me -_- I changed the filename of the file they were spam downloading and now they are just going to the old filename and getting 404 errors, how do I ban their ip with apache? I am on windows xp pro if that matters.
1 - 11 of 11 Posts

·
Registered
Joined
·
947 Posts
Yeah, drop it in your root. Just use notepad or whatever.
(Put quotes around it when you save it as ".htaccess" so it won't append it with .txt)

Looking around, looks like on Windows you may need to edit the httpd.conf

This guy has an amusing writeup


http://forums.livingwithstyle.com/ar...t149577p1.html

Sorry, never done it on Windows.
 

·
Registered
Joined
·
947 Posts
Been a while since I have used Apache (I could have this done in a half second in IIS...)

Your .htaccess file would look something like:

<Files *>
order allow,deny
deny from 127.0.0.1
allow from all
</Files>

Just replace 127.0.0.1 with the IP you want to block.
You can also block by domain - replace IP with "blah.com" (no quotes)

I think I remember always useing this directive too:

<Files .htaccess>
deny from all
</Files>

Also, your deny line can using masking or multiple entries.. I highly recommend against using domain names - else Apache has to go out and resolve names (big perf hit.)

So a deny line could look like:
deny from 127.0.0.1 127.0.0.2

Blocked two IPs.

Or:

deny from 127.0.0

You blocked that whole subnet.

You should also kill directory browsing using DirectoryIndex.
 

·
Premium Member
Joined
·
6,686 Posts
Discussion Starter · #9 ·
So basicly I have a file called .htaccess in my root folder and inside that folder i have

<Files *>
order allow,deny
deny from 127.0.0.1
allow from all
</Files>

where 127.0.0.1 is the ip I want to block.

Is that the only thing I have to do, or do I need to configure something else since im on windows?

EDIT: How do I make a file named .htaccess, it wont let me start a filename with a .
 

·
Registered
Joined
·
947 Posts
In notepad, put quotes around ".htaccess"

It will let you. (Wait, what OS are you on?)

Edit:
And ifn you really want to run apache, I recommend a move to *ux. Running it on Windows is like putting a Chevy engine in a Toyota.
Sure, it can work. But why try?
 

·
Registered
Joined
·
15 Posts
because satan

Sometimes a chevy smallblock in a lfited bob flat bed toyota running on 36 M/Ts with more armour than a bradley and more weight to drag over rocks is just simply needed.

besides the horsepower gains your also looking at a much cooler offroading rig.

oops this is a computer forumn
sorry

:)
 
1 - 11 of 11 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top