WordPress Optimized!

More than just another WordPress site

Menu
Skip to content
  • Home
    • Privacy
    • Disclaimer
  • Index
  • Plugin
  • Errors
  • Troubleshooting
  • Security
  • Code Snippet
  • Performance
  • 2BearStudio
  • Posted on April 17, 2014May 5, 2014
  • by Jerry Wang

Password Protect WordPress Admin Directory (wp-admin) for Enhanced Security

Everyone knows WordPress well type http://URL/wp-admin for login, so does hacker. Other than using stronger password, there is another way to protect yourself. That is “password protect admin directory”. It adds and additional level of security, works somewhat like two-step authentication. This can be very easy to implement and effective for website with handful of users.

There are two ways to password protect a directory.

Using cPanel Interface

Step 1: In cPanel, open “password protected directories” in security section
cpanel-security-section
Step 2:
Select your website directory.

Step 3: Select wp-admin folder.
select-password-directory

Step 4: Now check Password protect this directory and Name the protected directory something like “Protected Admin Panel”. Create username and (a strong) password for wp-admin directory, then click Save.

cpanel-password-protect-directories

That’s it. Now clear browser cache and open wp-admin page, you should be prompted with a pop-up box asking for username & password before you can get to the familiar WordPress wp-admin login interface.

 

Password Protect Directory using .HTACCESS (the Manual method)

What we did using cPanel is activating the directory protection by creating following content in the .HTACCESS file in the specific directory (wp-admin).

AuthName "Protected Admin Panel"
AuthType Basic
AuthUserFile /path/to/your/directory/.htpasswd
AuthGroupFile /dev/null
require valid-user

.htpasswd is the file that stores username & encrypted password for the password protected directory. For security purpose, cPanel app put this file out of the regular public_html folder. Instead of

/home/username/public_html/wp-admin

you should find this line in the .HTACCESS file

/home/username/.htpasswds/public_html/wp-admin/passwd

There are quite a few ways to create / add user & encrypted password to the password file. You can either using online version Htpasswd Generater, or Linux command line.

 

Apparently, this added security can be troublesome for you, the developer and site owner. To exclude trusted users from the extra layer of security, I normally add their machine’s IP address to trusted list. Now let’s edit the .HTACCESS file as following:

AuthName "Protected Admin Panel"
AuthType Basic
AuthUserFile /path/to/your/directory/.htpasswd
AuthGroupFile /dev/null
require valid-user

    Order deny,allow
    Deny from all
    Allow from XXX.XXX.XXX.XXX
    Satisfy Any

 

You may also want to add following code to it, in case the “Password Protected” wp-admin security measure breaks the Ajax functionality in some themes or plugins that use ajax in the front-end.

<Files admin-ajax.php>
    Order allow,deny
    Allow from all
    Satisfy any
</Files>
Password Protect WordPress Admin Directory (wp-admin) for Enhanced Security was last modified: May 5th, 2014 by Jerry Wang

Related posts:

  1. WordPress Security with WPScan: Username
  2. Manually Reset WordPress User Password
  3. Password Protect wp-login.php
  4. WordPress Security Tips: What Should Be Done after WordPress Installation
  5. WordPress Security Tip: Lock Down File Access
Posted in Code Snippet, SecurityTagged Login, Security

Post navigation

Prev Safe and Easy Terminal Login with SSH Config File
Next Password Protect wp-login.php

Recent Posts

  • Make Uncode theme working on your DreamHost shared hosting account
  • Remove /?doing_wp_cron from URL
  • My New iMac Setup Troubleshooting
  • How to Replace Huge Image with Optimized Version the Easy Way
  • How to disable Guternberg Editor – the new Block Editor in WordPress 5
  • How to increase Max Input Vars on DreamHost shared hosting account
  • How to Upgrade to WordPress 5.0 without losing Classic Editor
  • WordPress Security Tip – Avoid using these usernames
The Ultimate Managed Hosting Platform

Recommended WordPress Hosting

Web Hosting  Fastest WordPress Hosting

Coupon & Promotion

  • 10% saving on S2Member Pro (Single-site)
  • 10% saving on S2Member Pro (Unlimited-site)
  • Hostgator 25% off coupon: 25offhosing

WordPress Themes & Plugins

 

Tags

.htaccess 404 500 add_filter() Admin Archive Backup BackWPup Block Editor Coda Cron Custom Post Type DreamHost Email Error Guternberg Hack IfModule Login Membership Menu mobile password Performance PHP Plugin redirect Registration Responsive Revision Search Security Settings SSH Theme Troubleshooting Update WooCommerce wp- WP-CONFIG.PHP wp-login.php wp_query() wp_redirect() WP_TEMP_DIR WSOD

Recommended Plugins

  Gravity Forms Plugin for WordPress   s2Member® (WordPress Membership Plugin)

Categories

  • Code Snippet (30)
  • General (17)
  • Mobile (3)
  • Performance (9)
  • Plugin (23)
  • Security (17)
  • Troubleshooting (29)

Archives

© Copyright 2023 – WordPress Optimized!
Retina Theme by WPAisle ⋅ Powered by WordPress