Deny all, allow only one IP through htaccess

This can be improved by using the directive designed for that task.

ErrorDocument 403 /specific_page.html
Order Allow,Deny
Allow from 111.222.333.444

Where 111.222.333.444 is your static IP address.

When using the "Order Allow,Deny" directive the requests must match either Allow or Deny, if neither is met, the request is denied.

http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order


I know this question already has an accepted answer, but the Apache documentation says:

The Allow, Deny, and Order directives, provided by mod_access_compat, are deprecated and will go away in a future version. You should avoid using them, and avoid outdated tutorials recommending their use.

So, a more future-proof answer would be:

<RequireAll>
    Require ip xx.xx.xx.xx yy.yy.yy.yy
</RequireAll>

Hopefully, I've helped prevent this page from becoming one of those "outdated tutorials". :)


order deny,allow
deny from all
allow from <your ip> 

Tags:

.Htaccess