How to Restrict WordPress Admin Access by IP

Are you concerned about the security of your WordPress site? and want to secure the WP Administrative panel? Restrict admin access by IP Address is an effective way to secure your WordPress admin panel. In this tutorial, we’ll show you how to restrict WordPress admin access by IP using HTACCESS.

Allow Access to WP Admin from specific IP

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

Create a new .htaccess file and upload 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 allow from IP on each new line.

allow from 172.94.37.33
allow from 192.210.161.111
allow from 198.46.154.184

Block IP Address to Access WP Admin

If you don’t want to block every IP but specific IP to access WP Admin, you can block that IP address individually using the .htaccess file.

Create a new .htaccess file and upload 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>

Note that: Don’t forget to replace the IP address with your own.

Do you want to get implementation help, or enhance the functionality of this script? Click here to Submit Service Request

3 Comments

  1. Nuno Morais Sarmento Said...
  2. Dinesh Kumar Said...
  3. Daryl Snowden Said...

Leave a reply

keyboard_double_arrow_up