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 ?
Step 1: Generate the Country's IP Addresses Select the countries you want to block or allow. On the Select Format section, choose Apache . htaccess Deny or Apache . htaccess Allow.
Copied! If you're currently testing your site or setting it to maintenance mode, you might want to restrict visitors from accessing it. You can do so by adding the deny from all command to .
Go to Hosting → Manage → IP Manager: There, you will be able to find 2 options: add IPs to allow and block access to your website: Just add an IP you wish to create rules for, leave a note (optional) and click on Add.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With