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 ?
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 ?
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.
You have the correct syntax:
order deny,allow
deny from all
allow from 127.0.0.1
(Note: no quotes around the IP address)
You may want to double check you are using the correct IP Address if you are being denied when you think you should have access.
For example, check on http://www.whatsmyip.org/ - maybe you have something in between you and the server, like a proxy, which is being picked up, rather than your own IP Address.