Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's probably quicker to use htaccess since you won't need to run the php handler to run your php script. There's a similar answer that I gave <a href="https://stackoverflow.com/a/15580768/851273">for <strong>blocking</strong> IP addresses</a> which utilizes the <code>RewriteMap</code>. You'd just need something the other way around, instead of denying access from those IPs, grant access:</p> <pre><code>RewriteMap allow_ips txt:/path/to/allow_ips.txt RewriteCond ${allow_ips:%{REMOTE_ADDR}|0} =1 RewriteRule ^protected/path - [L] RewriteRule ^protected/path - [L,F] </code></pre> <p>The contents of the allow_ips .txt file would be:</p> <pre><code>12.34.56.78 1 11.22.33.44 1 etc. </code></pre> <p>The <code>RewriteMap</code> directed <em>must be in either the server or vhost config</em>. You can define a map from htaccess, though you can use it there.</p> <p>If you can't use maps, then you'll need to enumerate all the IPs with an <code>Allow</code>. In the htaccess file in the directory you want to protect:</p> <pre><code>Order Allow,Deny Deny from all Allow from 12.34.56.78 Allow from 11.22.33.44 ... </code></pre> <blockquote> <p>Is there a better way?</p> </blockquote> <p>The best way is probably to implement a user/password via htpasswd. <a href="http://www.javascriptkit.com/howto/htaccess3.shtml" rel="nofollow noreferrer">Here's a tutorial</a>. Then you can put the <code>Auth*</code> stuff in an htaccess file in the directory you want to protect and that's that. Simple.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload