Learn how to fix WP – Beginner’s Guide for WordPress

Learn how to limit IP access to your WordPress wp-login.php file

Learn how to limit IP access to your WordPress wp-login.php file

Do you want to restrict access to your WordPress wp-login.php file based on an IP address?

DDoS assaults and hackers often target the WordPress login page to access your website. Such attacks may be successfully thwarted by restricting access to certain IP addresses.

This post will show you how to quickly block access to your WordPress wp-login.php file based on an IP address.

Learn how to limit IP access to your WordPress wp-login.php file

Why Is WP-Login.php Access Restricted by IP Address?

Users go to the login page for a WordPress website, which is commonly wp-login.php, to log in to your site.

It grants you access to the WordPress admin area as the website owner, where you may manage, update, and maintain your website.

However, many internet brute force assaults are known to target the wp-login.php page to enter websites. They can still be able to slow down or even crash your website even if they are unsuccessful in getting in.

One way to deal with this is to block the IP addresses from which the attacks are coming (we’ll talk more about this later in the article).

An internet computer’s IP address serves as its unique identification, similar to a phone number. Software is available for hackers to alter their IP addresses.

A bigger pool of IP addresses is used in increasingly sophisticated assaults, so it may not be able to ban them altogether.

In such a situation, you may restrict access to certain IP addresses that you and other website users who use those IP addresses use.

So, let’s look at three different ways, including the Cloud Security Firewall, to quickly block access to the wp-login.php file from certain IP addresses.

1. Limiting IP access to the WordPress login page.

You must modify the .htaccess file to use this technique.

The root folder of your website has a unique server configuration file called .htaccess, which may be viewed using FTP or the File Manager tool in your WordPress hosting control panel.

Simply use an FTP program to connect to your WordPress site, then modify your .htaccess file and add the following code at the top.

1
2
3
4
5
6
7
8
9
10
11
<Files wp-login.php>
        order deny,allow
        Deny from all
 
# whitelist Your own IP address
allow from xx.xxx.xx.xx
 
#whitelist some other user's IP Address
allow from xx.xxx.xx.xx
 
</Files>

Don’t forget to substitute your IP addresses for the XXS. By going to the SupportAlly website, you may quickly determine your IP address.

supportally

You may ask other users to provide their IP addresses if they need to check in to your website with them. Then you may also include them in the .htaccess file.

Here is another example of the code given before.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<Files wp-login.php>
        order deny,allow
        Deny from all
 
# Whitelist John as website administrator
allow from 35.199.128.0
 
#Whitelist Tina as Editor
allow from 108.59.80.0
# Whitelist Ali as moderator
allow from 216.239.32.0
 
</Files>

The wp-login.php file may now be seen and used to connect to your website by people with these IP addresses. The following error message will appear to other users:

forbidden error

2. Preventing Particular IP Addresses from Visiting Your Website

This approach is completely the antithesis of the first.

You will be able to restrict IP addresses that are used to attack your website instead of limiting access to the WordPress login page to certain IP addresses.

This method is very useful for WordPress membership sites, online shops, and other sites where a lot of people have to sign in to get to their accounts.

The problem with this method is that hackers could keep coming back to your site by changing their IP addresses.

Fortunately, a lot of popular WordPress hacking efforts use a set of fixed IP addresses, making this technique generally successful.

Find the IP addresses you wish to block in step one.

Finding the IP addresses used to attack your website is the first step.

Examining your server logs can help you discover the problematic IP addresses the quickest. Simply click on the symbol that resembles a log file in the control panel for your hosting account.

raw access logs

To obtain the access logs, click on your domain name on the following page. A file with the .gz extension will be downloaded.

You must extract the file and use a text editor like Notepad or TextEdit to see it.

From this point on, you may discover the IP addresses that often access the wp-login.php page.

The IP addresses should be copied and pasted into a different text file on your computer.

Blocking unwanted IP addresses is step two.

After logging in, choose the IP Blocker icon in your WordPress hosting control panel.

ip blocker

Copy and paste the IP addresses you wish to block on the following page, then click the Add button.

block ip address

To block any other suspicious IP addresses you want, repeat the procedure.

That’s it. You were able to entirely prohibit shady IP addresses from visiting your website.

If you need to unblock one of these IP addresses in the future, you can do so easily with the IP blocker app.

unblock ip addresses

3. Using a website firewall to secure the WordPress login

You may not want to spend a lot of time as a website administrator controlling which IP addresses may access your WordPress login page.

Using the Sucuri plug-in is the simplest approach to secure your WordPress login pages. It is the top WordPress firewall that comes with a complete security plugin for WordPress.

Sucuri’s website firewall stops suspicious IP addresses from getting to important WordPress core files, so they can’t get to your website.

how sucuri works

This technique also helps WordPress function more quickly and effectively by preventing suspicious activity from slowing down your server.

Sucuri plug-in additionally has a built-in CDN network on top of that. It would automatically provide static content from a server closer to your users, such as photos, stylesheets, and JavaScript.

It is simple to put users’ IP addresses on a whitelist if they are unable to access WordPress login pages.

whitelist ip address

We hope that this post has shown you how to restrict access to your wp-login.php file based on an IP address. Read our “How to Transfer Your WordPress.com Blog to WordPress.org” as well if you want.

Learn how to limit IP access to your WordPress wp-login.php file

Previous Post
Next Post