View Full Version : How to Password Protect a .html file
grobert14
10-25-2007, 06:58 AM
I want to have a .html file in my publuc_html to require a password before the page loads up, and I tried the PP directory, but it seems to PP a folder, not a .html file, which is what I want.
How do I PP a .html file?
Early Out
10-25-2007, 07:26 AM
I don't believe there's any way to put a password on a file. But there's an easy way around it. Let's say you want to password-protect something.html. Create a subdirectory for it, like public_html/prot. Put a password on the prot subdirectory. Now, any link that points to www.yourdomain.com/prot/something.html will demand a password.
grobert14
10-25-2007, 09:17 AM
I don't believe there's any way to put a password on a file. But there's an easy way around it. Let's say you want to password-protect something.html. Create a subdirectory for it, like public_html/prot. Put a password on the prot subdirectory. Now, any link that points to www.yourdomain.com/prot/something.html will demand a password.
How would I set a folder within the public_html to be password protected and anything in that folder would require the password?
Early Out
10-25-2007, 10:46 AM
Once you've created the folder (in File Manager or from your FTP client program), open the Control Panel, select Password Protect Directories, and select the folder by clicking on its name.
This is where it gets a little tricky. First, check "Password protect this directory," and click Save (you don't need to "name" the protected directory).
Now, let's say you want to allow anyone in your family to access this folder. Create a user, maybe called "family," give that user a password, and click Add/modify authorized user. Now you can tell the people in your family that if they want to see the page in that directory, they'll be prompted for a username and a password, that the username is "family," and the password is whatever you've set it to.
grobert14
10-25-2007, 11:54 AM
I don't believe there's any way to put a password on a file. But there's an easy way around it. Let's say you want to password-protect something.html. Create a subdirectory for it, like public_html/prot. Put a password on the prot subdirectory. Now, any link that points to www.yourdomain.com/prot/something.html will demand a password.
Once you've created the folder (in File Manager or from your FTP client program), open the Control Panel, select Password Protect Directories, and select the folder by clicking on its name.
This is where it gets a little tricky. First, check "Password protect this directory," and click Save (you don't need to "name" the protected directory).
Now, let's say you want to allow anyone in your family to access this folder. Create a user, maybe called "family," give that user a password, and click Add/modify authorized user. Now you can tell the people in your family that if they want to see the page in that directory, they'll be prompted for a username and a password, that the username is "family," and the password is whatever you've set it to.
Edit: Now it is working, but it repeats the pop up password request over and over again.
Early Out
10-25-2007, 12:42 PM
Hmm... I think it will demand a password every time it accesses anything in that directory. So, if the page is there, but also all of the images that appear on that page, I think it's going to demand the password for each image display. I suspect this can be avoided by storing only the page itself in the protected directory.
If I have some time later, I'll play with it and see if I can figure out what it's doing.
Early Out
10-25-2007, 12:57 PM
I just did a little quick test, and it worked like a charm. I created a protected subdirectory, and put an HTML page in it, along with a few design elements (some arrow GIFs and a JPG). Attempting to access the page produces a prompt for a username and password.
Once I've entered those, I can visit the page, go elsewhere and come back to it, refresh it, and so on. It doesn't demand the password for each item on the page (which would be a huge PITA!). It only forgets who I am if I close the browser session, then come back to it.
If you're seeing repeated prompts, there must be something else wrong. I get a repeated prompt only if I keep entering an incorrect username or password.
grobert14
10-25-2007, 12:59 PM
Hmm... I think it will demand a password every time it accesses anything in that directory. So, if the page is there, but also all of the images that appear on that page, I think it's going to demand the password for each image display. I suspect this can be avoided by storing only the page itself in the protected directory.
If I have some time later, I'll play with it and see if I can figure out what it's doing.
Okay, thank you.
A bit more detail:
I have a sub-domain that is for someone that I am making a website for. There is a page which is password protected, and in that page I want it to request a password if you enter the url to it.
So for example:
www.subdomain.mydomain.com/passwordprotectedpage
And I wanted it so that if you enter the url like the example above, before the page would load it would ask for a password.
grobert14
10-25-2007, 01:01 PM
I just did a little quick test, and it worked like a charm. I created a protected subdirectory, and put an HTML page in it, along with a few design elements (some arrow GIFs and a JPG). Attempting to access the page produces a prompt for a username and password.
Once I've entered those, I can visit the page, go elsewhere and come back to it, refresh it, and so on. It doesn't demand the password for each item on the page (which would be a huge PITA!). It only forgets who I am if I close the browser session, then come back to it.
If you're seeing repeated prompts, there must be something else wrong. I get a repeated prompt only if I keep entering an incorrect username or password.
Well, what I think is wrong is that the main page is for some reason password protected as well as the link inside the main page. Does that affect it, or not?
Early Out
10-25-2007, 01:03 PM
Try my test page. Head to:
[test site removed - problem solved]
Use username grobert14 and password 12345678.
The same routine should work just fine with a subdomain (by the way, the proper URL for a subdomain is http://subdomain.mydomain.com, without the leading "www").
Early Out
10-25-2007, 01:07 PM
Well, what I think is wrong is that the main page is for some reason password protected as well as the link inside the main page. Does that affect it, or not?I don't think that's what's happening. Remember, you can't password-protect a page - you can only password-protect a directory.
Let's say you've got a subdomain called http://dogs.pets.com. You can put a password on public_html/dogs, and create one or more user accounts, and then only those with a username and password could access anything in the subdomain. If you want to protect only one part of the subdomain, like the pedigree.html page, you can store that page at public_html/dogs/pedi/pedigree.html, and put a password only on the "pedi" subdirectory, not on the "dogs" level.
grobert14
10-25-2007, 01:22 PM
I don't think that's what's happening. Remember, you can't password-protect a page - you can only password-protect a directory.
Let's say you've got a subdomain called http://dogs.pets.com. You can put a password on public_html/dogs, and create one or more user accounts, and then only those with a username and password could access anything in the subdomain. If you want to protect only one part of the subdomain, like the pedigree.html page, you can store that page at public_html/dogs/pedi/pedigree.html, and put a password only on the "pedi" subdirectory, not on the "dogs" level.
I think I solved the problem. It's doing what I want it to do.
Thank you for your help and your examples. I will let you know if something bad happens again. :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.