Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this set in my .htacess file:

Order Allow,Deny
Deny from all
Allow from localhost
Allow from 86.101.198.88 (my ip)

ErrorDocument 404 /block/?code=404
ErrorDocument 403 /block/?code=403

But for some reason, I don't have permission to access from localhost and using my IP either. I just keep getting redirected to the ErrorDocument for error 403. What am I missing?

share|improve this question
up vote 2 down vote accepted

From https://httpd.apache.org/docs/2.0/mod/mod_access.html

Allow,Deny First,

all Allow directives are evaluated; at least one must match, or the request is rejected. Next, all Deny directives are evaluated. If any matches, the request is rejected. Last, any requests which do not match an Allow or a Deny directive are denied by default.

Since you have a Deny from all, and your order is Allow,Deny, everything will be blocked. You probably want order Deny,Allow instead.

Deny,Allow

First, all Deny directives are evaluated; if any match, the request is denied unless it also matches an Allow directive.

share|improve this answer
    
Oh wow, it's that simple? Thanks! – SeinopSys Apr 24 '13 at 21:39
    
+1. I've always hated these directives for not making any damn sense except perhaps to people with a Ph.D. in mathematics. Fortunately it's been replaced in 2.4 with a system that actually makes sense to the rest of us. – Michael Hampton Apr 24 '13 at 21:41
    
I highly suggest you edit some of what @MichaelHampton linked into the answer, because this question has been getting quite a few hits recently and people might actually be looking for the 2.4 solution instead when they find this question. – SeinopSys Mar 7 at 20:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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