On a Godaddy hosted website I wanted to do two things. First, I wanted to allow users to view list of files in the directory. Second, I wanted to password protect that directory.
I've used htaccess before, but not often enough to really understand it. However, a bit of googling and I was ready to go.
I started off with the directory listing side of things. Using a simple text editor I made a one line file containing this command:
Options +Indexes
Windows doesn't like saving a filename with no name before the dot so it balks at naming a file .htaccess. The solution is to save it in quotes:
".htaccess"
I ftp'ed it to the directory and it immediately disappeared (it's supposed to). The first time you upload htaccess to godaddy it takes awhile to be recognized. Give it about 10 minutes. After that, changes to htaccess (and htpassword) are immediate. Once it was recognized, I used my web browser to navigate to the directory it worked.
I had one complaint, the filename column was too narrow. A little more googling and I came up with the fix of adding a second line:
IndexOptions NameWidth=*
That caused the filename column to expand to whatever size it needed to to display the full file name.
Now, I was ready to go for password protection. Godaddy's help files describe the process. First, I added to .htaccess
AuthName "User Name and Password Please"
AuthUserFile /home/content/x/x/x/xxxname/html/.htpasswd
AuthGroupFile /dev/null
AuthType Basic
<_limit GET POST_> (remove the underscores)
require valid-user
<_/limit_>
The main thing you have to understand is the "x's." Let's say your godaddy username is "scott." In that case you replace the x's with the first three letters of scott (letter case matters). Now that line would read:
AuthUserFile /home/content/s/c/o/scott/html/.htpasswd
Or another example, say the username is "Pastor." Now that line is:
AuthUserFile /home/content/P/a/s/Pastor/html/.htpasswd
One caution - and this cost me about an hour. I was so focused on the /home/content/e/t/c stuff that I forgot to designate the actual directory. I wasn't changing .htaccess for the root (html) directory, but a sub directory. Therefore, I needed to add the directory to the above command:
AuthUserFile /home/content/x/x/x/xxxname/html/password-protected-dir/.htpasswd
That line has to point to the actual location of .htpasswd! After an hour or so the light finally dawned on me - hopefully this will save you that hour of frustration!
Next, we create the .htpasswd file - following the same approach we used for the creation of the .htaccess file.
Do a google search for "htpasswd creation" - you'll find many websites that will hash the password for you. Once you get it, the .htpasswd file will contain lines like this:
username:hashed-password
Upload it to the directory and you should now have a password protected directory.
Sermon Podcast - General Writing From Pastor Scott
Home Page of Pastor Scott - Church
On Monday, November 17, 2008 Pastor Scott wrote:
htaccess htpasswd and Godaddy
Subscribe to:
Post Comments (Atom)

0 Your comments are welcome:
Post a Comment