Password Protecting Subdirectory Issues
-
I have a subdirectory (/corporate) that was manually made and resides alongside the regular WordPress directories (/wp-content, /wp-admin, etc.) that I would like to be password protected. Within the /corporate directory, I have created an .htaccess file and .htpasswd file.
The .htaccess file
AuthUserFile /var/www/vhosts/[websitename]/http/corporate/.htpasswd AuthGroupFile /dev/null AuthName "Requires Access. Contact Team for a Login" AuthType Basic Require valid-user
My .htpasswd file
This file was created via ssh through the command,
$ htpasswd -c /var/www/vhosts/[websitename]/http/corporate/.htpasswd test
and looks like:test:ztNWne3fVjJ0.
When navigating to the URL, [website]/corporate, the authentication window will appear, and will only accept the correct credentials if the user is logged into the WordPress dashboard otherwise the authentication window will simply refresh again and again. There is no indication within the website logs, nor in the Apache logs why the authentication only works while logged into the dashboard.
Troubleshooting steps attempted thus-far
- Changed permalink settings (http://support.hostgator.com/articles/specialized-help/technical/wordpress/wordpress-preventing-you-from-password-protecting-a-directory)
- Moved the .htpasswd file outside of the website directory
- Excluded the /corporate directory from the main WordPress .htaccess file (http://stackoverflow.com/questions/2322559/htaccess-wordpress-exclude-folder-from-rewriterule)
- Prevented WordPress rewrite from modifying the /corporate directory through
mod_setenvif
(http://stackoverflow.com/questions/27705412/htaccess-authentication-with-wordpress) - Moved the .htaccess logic into the main apache configuration file
None of the above troubleshooting steps changed the behavior of the authentication only being accepted while logged into the WordPress dashboard. I am hesitant to deactivate the plugins used on the site since this issue is ONLY happening on the live production site, but works perfectly well on the staging environment of the site (hosted on a different server, but otherwise nearly identical).
I’m now at a complete loss and any further suggestions would be IMMENSELY appreciated. I’d be happy to provide any additional information required.
Thanks
- The topic ‘Password Protecting Subdirectory Issues’ is closed to new replies.