Indian company. Since 2018.
Security

Restrict Directory Access by IP Address with .htaccess

20,147 genuine article views Security

Tip: if you cannot see the .htaccess file in cPanel File Manager, enable Show Hidden Files (dotfiles) in File Manager settings.

You can restrict access to a directory by allowing only specified IP addresses in its .htaccess file. For example, to limit access to a WordPress admin directory, create or edit /wp-admin/.htaccess and add:

Order deny,allow
Deny from all
Allow from YOUR-IP-ADDRESS-HERE

Replace YOUR-IP-ADDRESS-HERE with the IP address you want to allow. To allow additional addresses, add a separate Allow from line for each one.

Test the restriction by accessing the directory from an IP address that is not allowed. If your server uses Apache 2.4 or later, the legacy directives above may require the mod_access_compat module. Otherwise, use this equivalent configuration:

Require ip YOUR-IP-ADDRESS-HERE