views:

109

answers:

3

I am having problems as some computer from an IP address is trying to access all the files on my server.

How should I change the htaccess file so that IP address gets NO access at all to any files? And which htaccess file do I change? It looks like I have one inside each folder.

+3  A: 

The basic mod_access module should get you what you need

Order allow,deny
Allow from all
Deny from xxx.xxx.xxx.xxx

Something like that. I dont know the exact syntax. Keep in mind that depending on your exact version of Apache (1.3/2.0/2.2) then the module requirements might be different. I think in 2.2 you need the authz_host module, but in 1.3 its mod_access.

Cody Caughlan
which htaccess file do i add this to?
chris
You would probably want to put it in the root of your app (whether thats the overall document root of your site, I dont know). But yeah, the application root.
Cody Caughlan
+1  A: 

For simple cases, you can try http://wordpress.org/extend/plugins/wp-ban/, which can keep IP or IP range from visiting your blog.

If that's not enough, you can modify .htaccess as follows

Deny from xx.xx.xx.xx/xx

Allow from ALL

ZelluX
+1  A: 

Another way, this time using mod_rewrite rules in a .htaccess file.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^123.123.123.123$
RewriteRule ^(.*)$ blocked.html [L,F]

[L,F] means 'stop executing further rules, and return 403 Forbidden as the HTTP status'. blocked.html could contain a message indicating that they've been blocked.

ceejayoz
does this block all files and folders inside the server? do i have to wrap it with <files></files> or something?
chris
Yes, this will block all files and folders (^(.*)$ means match every URL). No need for a wrapper.
ceejayoz