The accepted answer below is the correct one assuming (as I thought) that the server is v2.2.

Instead, I discovered the server is apache 2.4 instead, so the real solution was to use the new directives. Please see my comment below the accepted answer.


in mydomain.com/wp-admin I placed a .htaccess with something like

# note: the ip here is a fake
order deny,allow
deny from all
allow from

But I now get a 403 error. The domain and IP here are fake, but the real IP I'm using is correct since I can see it form logs, that are something like:

www.example.com - - [10/Jan/2017:10:51:52 +0100] "GET /wp-admin/ HTTP/1.1" 403 518 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:50.0) Gecko/20100101 Firefox/50.0"

So it's really strange, I should be able to enter. Any Idea?


Read Order directive documentation.

You need something like:

order allow,deny
deny from all
allow from
| improve this answer | |
  • 2
    Just to quickly explain it for him: the order in which you write the commands (allow/deny) in the "order" row decides what your server interprets first. In your case you first write "deny" and then later "deny from all". Since the deny command has higher priority your server denies all and doesnt even check for anymore, since you already denied all connections for all. If you write order allow,deny your server first allows and then denies everyone else. – Broco Jan 10 '17 at 14:16
  • Ok, I discovered that the real problem was in fact the apache version! ;) On that server it's 2.4, and those directives are not supported anymore. The solution was to use new directives like Require ip xxx.xxx.xxx.xxx or Require all denied. See here – Luca Reghellin Jan 13 '17 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.