- Log in to cPanel.
- For help accessing your cPanel see Where do I log in to my hosting control panel
- Click Directory Privacy
- Click the folder icon next to public_html
- Click wp-admin
- Check Password protect this directory
- Enter WordPress Admin for Name then click Save
- Click Go Back
- Under Create User enter a Username, click Password Generator to create a strong password.
- Save the password for later, click I have copied this password in a safe place and click Use Password
- Click Save at the bottom of the page
- Click Search Features and type File Manager. Click File Manager
- Open your public_html directory
- Open wp-admin
- Select .htaccess and click Edit
- At the top of the file enter the code below:
ErrorDocument 401 "Unauthorized" ErrorDocument 403 "Forbidden" # Allow admin-ajax.php access <files admin-ajax.php> Order allow,deny Allow from all Satisfy any </files>
Click Save Changes
- Click Close
- Click public_html on the left
- Select .htaccess and click Edit
- At the top of the file enter the code below
ErrorDocument 401 "Unauthorized" ErrorDocument 403 "Forbidden" <filesmatch "wp-login.php"> AuthType Basic AuthName "WordPress Admin" AuthUserFile "/home/example/.htpasswds/public_html/wp-admin/passwd" require valid-user </filesmatch>
Note: Replace *example* with your cPanel username - Click Save Changes
Open your WordPress Dashboard. You should see a prompt for a username and password. Enter your username and password you created earlier to login.