Solving 404 Errors When Using Htpasswd

One of our Pro support members was having trouble getting into the admin section of his website. He was getting a 404 error. No recent changes had been made to the site and it was working fine a few days ago.
We debugged the issue for him and it ended up being an issue with an Apache update and an incompatible htaccess/htpasswd rule. This tutorial will show you the fix.
Troubleshooting
First off, I disabled the .htaccess file and checked the admin. It indeed worked after disabling the file. The last edit on the file was months ago, so nothing had changed for it recently. The htpasswd file also hadn’t been changed in months.
Then I double checked the paths and those were all OK. Since nothing had changed, I suspected that it was a server issue of some kind.
The fix
It problem ended up being an Apache update and the new Apache version wasn’t compatible with legacy htaccess rules. It needed the following: ErrorDocument 401 "Authorisation Required"
So, this:
AuthType Basic AuthName "Secured Area" AuthUserFile "path/to/passwd" require valid-user
Became this:
AuthType Basic AuthName "Secured Area" AuthUserFile "path/to/passwd" require valid-user ErrorDocument 401 "Authorisation Required"
What is that line doing? It’s declaring the page to have a HTTP 401 error with a custom message of “Authorisation Required”. The 401 error is required by Apache to trigger the htpasswd file.
I hope this tutorial gets you out of a jam!
Thank you. That’s exactly what I didn’t. .htaccess wanted that 401 ErrorDocument.
Thank you! Just what I needed!
Glad to hear that helped, Anne
This was driving me mad! (Three Thumbs up to you sir!!!)
Solved my problem!! Thank you!
thanks, you save my life.
This just did the trick, thought I was losing my mind. Thank you
Thanks!
So many hours wasted before finding this quick and easy fix… Thank you, sir!
Wow, how did you figure that out?? 🙂
Nice work..
Thank you very very much!
You’re very welcome!
I think this may be what I need to resolve my problem: when I log in, I find myself in an endless loop to login and nothing has been changed since I was last able to log in. So… my questions:
1.) do I need to only change the “path/to/passwd” part (and not the “Secured Area”)?
2.) If so, where do I find this path/to/password?
Thanks much.
Thanks for this article, it was really helpful.
excellent!
Say I protected a website on an Apache server through an htaccess file, how would I allow for sub URLs to prompt for the login as well? Right now only example.com/ prompts for password and if try example.com/about it gives me a Not Found
Thanks for the solution!
So glad you found answers here at OST! Thanks for posting.
1 million thumbs up
Awesome! Very happy to be of help.
Thanks alot!
You’re welcome!
Thanks
thanks so much I needed that last line.