How to Restrict WordPress Admin Access by IP

Worried about the security of your WordPress site? And you want to protect the WP admin panel? Restricting WordPress Admin Access by IP address is an effective way to protect the WordPress management panel. In this tutorial, we will show you how to use HTACCESS to Restrict WordPress Admin Access by IP.

Allow Access to WP Admin from specific IP

The following example shows how to allow access to wp-admin from a specific IP address. It is very useful when you only want to allow access from your IP address.

Create a new .htaccess file and upload it to the wp-admin directory. Now insert the following code in wp-admin/.htaccess file.

order deny,allow
allow from 172.94.37.33
deny from all

If you want to allow access to wp-admin from multiple IP addresses, list them as to allow from IP on each new line.

allow from 172.94.37.33
allow from 192.168.161.110
allow from 198.128.15.184

Block IP Address to Access WP Admin

If you don’t want to block all IP addresses except a specific IP from accessing WP Admin, you can block that IP address individually using the .htaccess file.

Create a new .htaccess file and upload it to the wp-admin directory. Now insert the following code in wp-admin/.htaccess file.

order allow,deny
deny from 198.46.154.184
allow from all

Restrict Access by IP to wp-login.php file in WordPress

You can limit access to the wp-login.php file by IP address using HTACCESS. Open the main .htaccess file and insert the following code at top of the file.

<Files wp-login.php>order deny,allow
Deny from all

# allow access from my IP address
allow from 172.94.37.33

# allow access from my IP address
allow from 192.210.161.111
</Files>

0/5 (0 Reviews)

Leave a Comment