Problem
When you attempt to view a page that is located within a CMS (Drupal, WordPress, Joomla, etc) site folder and uses a .htpasswd file, you are redirected to the site’s 404 error page.
Cause
When authentication is needed, it may be searching for a files on the server with the name “401.shtml” or similar. This request is instead handled by the CMS and results in a 404 (not found) error.
Solution
This has been tested with Drupal but should work for other Content Management Systems.
- Open the site’s .htaccess file for editing.
- Look for the following lines of code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d - Change it to the following:
RewriteCond %{REQUEST_FILENAME} !\.shtml$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d - Save the updated file to the server.
THANK YOU. I was trying to create a secured folder outside of my wordpress installation using htaccess, but everytime I tried to access the secured portions, I’d get redirected to 404. This solved my problem perfectly. Thanks!!