Restricting Access via .htaccess (Technical Method)
If your website is hosted on an Apache server (which is very common), you can use the .htaccess file to block or allow connections based on the IP address.
- Connect to your server using FTP or your hosting control panel’s File Manager.
- Navigate to the
/wp-admin/directory of your WordPress installation. - Create or Edit a
.htaccessfile in this directory.
Add the following code to the .htaccess file, replacing the example IPs with your actual IP addresses:
Apache
# Protect wp-admin - Deny all, then Allow specific IPs
Order Deny,Allow
Deny from all
# Allow your personal or VPN IP address(es)
Allow from 192.168.1.100 # Replace with your first IP address
Allow from 203.0.113.42 # Replace with your second IP address (e.g., VPN IP)
What this code does:
Order Deny,Allow: Sets the rule logic to processDenyrules first, and thenAllowrules.Deny from all: Blocks every incoming connection attempt.Allow from [Your IP]: Overrides theDenyrule for the specific IP addresses you list, letting them through.
Save the file. This will immediately enforce the IP restriction for the /wp-admin/ folder and its contents.