Security & Protection3 min read•Updated September 2026

How to Restrict Directory Access to Specific Whitelisted IPs

Whitelisting allows access only to authorized IP addresses while denying all other requests. This is the gold standard for protecting WordPress administrative dashboards.

Step-by-Step Instructions

1

Navigate to the Target Folder

In File Manager, enter the directory you wish to lock down (e.g., /public_html/wp-admin/).

2

Create or Edit .htaccess Inside That Folder

Add a local .htaccess file inside that specific directory.

3

Add IP Whitelist Directives

Paste the following rule, replacing 203.0.113.50 with your actual static public IP address:

Require ip 203.0.113.50
Require ip 198.51.100.25

Related Guides in Security & Protection

How to Protect Your .htaccess File and Block Unauthorized Access

3 min read • Read →

How to Ban Malicious IP Addresses via .htaccess on LiteSpeed

2 min read • Read →

How to Protect a Directory with Username & Password in cPanel

3 min read • Read →
Chat with HubforHost on WhatsApp (+91 7780204727)