Prevent unauthorized WordPress wp-admin and wp-login.php attempts

 01.  Login in to cPanel

 02. Click Directory Privacy

 03. Click the folder icon next to public_html

 04. Click wp-admin

 05. Select Password protect this directory

 06. Enter WordPress Admin for Name then click Save

 07. Click Go Back

 08. Under Create User enter a Username, click Password Generator to create a strong password.

 09. Save the password, click I have copied this password in a safe place and click Use Password

 10. Click Save at the bottom of the page

 11. Go back to cPanel home page and click File Manager

 12. Open public_html directory

 13. Open wp-admindirectory

 14. Select .htaccess and click Edit

 15. Add below text in the file

ErrorDocument 401 "Unauthorized"
ErrorDocument 403 "Forbidden"

# Allow admin-ajax.php access
<files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</files>

 

   17. Click public_html on the left
   18. Select .htaccess and click Edit
   
19. 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/USERNAME/.htpasswds/public_html/wp-admin/passwd"
require valid-user
</filesmatch>

   20. Note: Replace *USERNAME* with your cPanel username
   21. Click Save Changes

 
 
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How do I embed a Facebook status in a WordPress post?

Facebook now allows you to embed a status update anywhere you want online. One popular place to...

Use .htaccess to block WordPress brute force attacks

WordPress has been targeted recently for brute force attacks where hackers use automated scripts...

Deleting post revisions from the WordPress database

One of the great features the WordPress added in was post revisions. Any changes made to posts...

Use .htaccess to block WordPress brute force attacks

WordPress has been targeted recently for brute force attacks where hackers use automated scripts...