Denying and Allowing Access

Deny except from specific IPs

Order deny,allow
Deny from All
Allow from xxx.xxx.xxx.xxx
Allow from xxx.xxx.xxx.xxy

Allow except from specific IPs

Order deny,allow
Allow from All
Deny from xxx.xxx.xxx.xxx
Deny from xxx.xxx.xxx.xxy

Comments

  1. User Avatar
    Abby Larsen
    Permalink to comment#

    If your server is running Apache 2.4 the syntax is a bit different. For example, this:

    Order deny,allow
    Deny from All
    Allow from xxx.xxx.xxx.xxx
    Allow from xxx.xxx.xxx.xxy
    

    Might need to be written as this, instead:

    Require host xxx.xxx.xxx.xxx
    Require host xxx.xxx.xxx.xxy
    

    There are more examples here: http://httpd.apache.org/docs/2.4/upgrading.html

    I ran into problems with the old syntax when setting up .htaccess passwords on a Digital Ocean server running Apache 2.4. Hope this helps someone!

Submit a Comment

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag