How to prevent access to WordPress blog by ip?

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.

Related posts

Leave a Reply

3 comments

  1. 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.

  2. 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.