Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to do a quick htaccess to block all but my ip.

I have this

    order deny, allow
    deny from all
    allow from "MY IP"

"MY IP" is my ip

I can't see if from my ip - is this the correct way to do this ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
274 views
Welcome To Ask or Share your Answers For Others

1 Answer

The most efficient way is to white list yourself using the directive designed for that task.

Order Allow,Deny
Allow from 123.456.789.123

Where 123.456.789.123 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

Or you could do it with mod_rewrite like so.

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^123.456.789.123$
RewriteRule .* - [F]

Note that 'RewriteEngine On' will be redundant if you already have placed in your rules above this one. So if that's the case you can discard it here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...