Two simple steps to protect your WordPress login page:
- Don’t use ‘admin’ as your user name. It’s been several years since WordPress stopped using ‘admin’ as the default user name, but many web designers keep using it.
- Use strong passwords. Passwords should not include dictionary words. Use at least 8 characters and include numbers, symbols (&, $, ;, etc) and mixed capitalization. Learn more on WordPress recommended strong passwords .
Step 1: Create the Password File
Create a file named
.wpadmin and place it in your home directory, where visitors can’t access it. The following example is for cPanel:
(where “username” is the cPanel username)
Put the username and encrypted password inside the
.wpadmin file, using the format
(where “john” is a username of your choice, and the password shown is encrypted.)
Generate Password File & Uploading Via File Manager
One way to do this is to generate the file using the website linked below, and then upload it to your site via FTP or File Manager. In the directions below, we will use File Manager, but you could use FTP instead, for those of you familiar with FTP.
- Visit: http://www.htaccesstools.com/htpasswd-generator/
- Use the form to create the username and password.
- Login to cPanel in another window or tab.
- Click on File Manager.
- Select Home Directory.
- Check Show Hidden Files (dotfiles) if not already checked.
- Click on the Go button.
- Look for a
- If one exists, right click on it and select Code Edit to open the editor. Click on the Edit button to edit the file.
- If one does not exist, click on New File at the top of the page, and specify the name as
.wpadmin(with the dot at the front) and click on the Create New File button.
- Paste the code provided from the website in step 2.
- Click on the Save Changes button when complete.
- You can Close the file when finished.
Step 2: Update the .htaccess File
All domains under the home directory will share the common
The last step is to place the following code in the
ErrorDocument 401 "Unauthorized Access"
ErrorDocument 403 "Forbidden"
AuthName "Authorized Only"