My host asked me to implement htaccess authentication to add an extra layer of security to my WordPress installation.
When accessing the WordPress admin area I am asked for a second (server) level of authentication. This is fine, however I have a page on my site that is pass protected. Unfortunately all users of this page are also being asked for the htaccess credentials.
Is there a better way to add this brute force protection? Or perhaps a way to exclude a specific page from requiring the second factor authentication?
Also, will the latter weaken and defeat the purpose of having the second login?
Here is the relevant code from the tutorial…
ErrorDocument 401 "Unauthorized Access"
ErrorDocument 403 "Forbidden"
<FilesMatch "wp-login.php">
AuthName "Authorized Only"
AuthType Basic
AuthUserFile /home/username/.wpadmin
require valid-user
</FilesMatch>
Edit: Also this method doesn’t seem viable for WP sites that have subscribers. Surely they would need to access wp-login.php.
Should work if you use the following directives:
What it does is, skipping the basic auth everytime the “action” string is provided and is “postpass”.
… just a thought:
I need to test it further myself, because i don’t know how it will affect the internal routing of WordPress e.g. /action/postpass/.
Why change the htaccess when you can change the WordPress password form. Here is something that worked for me.
You can exclude the page using a environment variable that matches against the requested URI:
So the directory where this htaccess file is placed will be password protected, except for requests to
/path/to/no-protect-page
.Try https://wordpress.org/plugins/better-wp-security/ ; https://wordpress.org/plugins/bulletproof-security/ or other security plugins on WordPress.