Limit Access Using htaccess

To limit access to a folder using .htaccess, create .htacess file with following content.

order deny,allow
deny from all
allow from YOUR_IP_HERE

YOUR_IP_HERE = Replace it with your actual IP.

You can white list IP range by entering CIDR notation for the IP range.

Here is .htacess i use on one of my web sites admin folder.

order deny,allow
deny from all
allow from 137.97.0.0/16
allow from 116.68.64.0/18

If your server is behind a reverse proxy server, you may need to use

Order Deny,Allow
deny from all
SetEnvIf X-Forwarded-For "103.35.199.82" OkAccess
SetEnvIf X-Forwarded-For "92.184.105.169" OkAccess
Allow from env=OkAccess

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *