Sometimes you want to only allow access from certain IPs, such as when having an admin only section on your site – denying access from all is easily controllable with .htaccess files on a per directory basis.
The below will limit all the get and post requests within a given directory, and all its subdirectories, you will need to place this in a file named .htaccess in the directory that you want to limit access to.
<Limit GET POST> order deny,allow deny from all # Allow Home IP allow from 10.0.0.2 # Allow Work IP allow from 10.0.0.4 </Limit>
The first line controls the order of the rule, setting this to deny,allow means that you will first have to write in the addresses that should be blocked – this can be an IP-range, a single ip, or a keyword. The All keyword was used in this example, and it will simply block access from all IPs, except for the ones that you type in. Simply replace 10.0.0.2 with your own IP, unless you are working on your LAN this should be your WAN IP.