How to Secure WordPress Login : Easy Steps

Secure WordPress Login
This article will help you know how to secure a WordPress login using password-protect in the WordPress login file.

Nowadays, hackers seem more interested in attacking WordPress sites. So here is a fast and easy method to prevent WordPress brute force attacks.

We are going to password protect our WordPress login file. Please follow the below steps to secure WordPress login.

1) Open your Apache main configuration file and add the following.

vi httpd.conf
<FilesMatch "wp-login.php">
AuthName "Please Authorize to Continue"
AuthType Basic
AuthUserFile /root/.htpasswd
require valid-user


Note: If you are using any other CMS, please find the login file and add that file in the “FileMatch” section.


2) Set up authentication

Create a password file with the user name “auth-usr”.

htpasswd -c /root/.htpasswd auth-usr


( You can also use this .htpasswd generator tool if you don’t like the command line way: )


3) Restart Apache to update these changes.

/etc/init.d/httpd restart


Done!! Now you need to provide this user name and password to access your login pages. It will work with all your WordPress sites—no need to create separate .htaccess files.

If you don’t have root access to the server or if you are on a shared environment, then you can add these same codes to your .htaccess file ( create one if you don’t have one already ) and create a .htpasswd file using and put it under your document root. ( Also make sure to change the AuthUserFile path )


So this is how you secure the WordPress Login page.

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

WordPress Management Plan

Focus on your business, and let us take care of your WordPress Websites!
From what you are reading, it seems you are interested in WordPress and related technologies. If you have a moment to spare, please take a look at our WordPress Management Plan, which might interest you even more!
WordPress Management Plan

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

ServerHealers uses cookies.