PrimitiveType

Fixing Apache Basic Auth error on GoDaddy


I just tried opening up the index page of a directory I had password protected with Apache Basic Authentication some time ago, to be greeted with an "Internal Server Error" message. There was never a problem accessing the page before, so why now?

As a bit of context, the site is hosted with GoDaddy.com on an Apache server, and Basic Authentication is achieved by placing a .htaccess file in the directory in question. The .htaccess file references the location of a .htpasswd file, which contains the user name and encrypted password needed to gain access to the pages within the protected directory. Here's the contents of the .htaccess file:

AuthUserFile /path/to/.htpasswd AuthGroupFile /dev/null AuthName EnterPassword AuthType Basic require valid-user

Upon close inspection I noticed that the path to the .htpasswd file was wrong. However, I had never changed the location of the file. It appears that the location of the site's document root was changed automatically when GoDaddy restructured directories on the server, or perhaps moved my site from one server to another. At any rate, fixing the path to the file solved the problem.

In this scenario I have used an absolute path to the .htpasswd file. If the path is not absolute Apache treats it as relative to its SERVER_ROOT location, which is not a directory a GoDaddy client can access on a shared hosting server. If you are using a virtual private server or a dedicated server, you will be able to access that location and store your .htpasswd file there if you so wish. But then, your paths are not likely to magically change so you may as well store it anywhere else you wish! Still, as a general rule of thumb, using relative paths makes sense most of the time.