WordPress is one of the most used CMS’ in the world. Recent stats indicate that nearly 90 percent of all the hacked websites were WordPress sites. But we can prevent such issues by restricting the IP Addresses on the WordPress Dashboard.
There are two methods to set IP Address restrictions –
- Adding a .htaccess to restrict IP Address
- Adding plugins to block IP Address
1. IP Address Restriction with .htaccess
- We can add a .htaccess file inside the wp-admin directory and add the content given below –
# order deny, allow
# Replace the below x.x.x.x with your IP address #
allow from x.x.x.x
deny from all
- Then add the IP address from which you want to allow the WordPress admin access.
2. Plugins to Restrict IP Address
- Log in to WordPress Dashboard.
- Click on Plugins.
- Adjacent to the Plugins option, click on Add New.
- Type WP Ban in the box beside the Keyword.
- Install and Activate the same Plugin.
- Now, click on Settings and then click on the Ban button.
Here, you can add IPs or IP Range in respective boxes as given in the screenshot below -
- Click on Save Changes.