Password Protect Wordpress Admin folder from the Server's side
1. Create your .htpasswd file by running the following command:
htpasswd -c /home/brendan/public_html/.htpasswd your_desired_username
(where you should change "your_desired_username" with the actual username that you want to use)
2. With the .htpasswd file now created under your /home/brendan/public_html/ directory, you can go ahead and add the password protection to your wp-login.php file.
You can do this by adding the following rules to the .htaccess file in /home/brendan/public_html/:
<Files wp-login.php>
AuthUserFile /home/brendan/public_html/.htpasswd
AuthName "Private access"
AuthType Basic
require valid-user
</Files>
3. Then create a new .htaccess file in your /home/brendan/public_html/wp-admin/ directory and put the following lines in it:
AuthUserFile /home/brendan/public_html/.htpasswd
AuthName "Private access"
AuthType Basic
require valid-user
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>
<Files "\.(css|gif|png|js)$">
Order allow,deny
Allow from all
Satisfy any
</Files>
###
htpasswd -c /home/brendan/public_html/.htpasswd your_desired_username
(where you should change "your_desired_username" with the actual username that you want to use)
2. With the .htpasswd file now created under your /home/brendan/public_html/ directory, you can go ahead and add the password protection to your wp-login.php file.
You can do this by adding the following rules to the .htaccess file in /home/brendan/public_html/:
<Files wp-login.php>
AuthUserFile /home/brendan/public_html/.htpasswd
AuthName "Private access"
AuthType Basic
require valid-user
</Files>
3. Then create a new .htaccess file in your /home/brendan/public_html/wp-admin/ directory and put the following lines in it:
AuthUserFile /home/brendan/public_html/.htpasswd
AuthName "Private access"
AuthType Basic
require valid-user
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>
<Files "\.(css|gif|png|js)$">
Order allow,deny
Allow from all
Satisfy any
</Files>
###
Comments
Post a Comment