PDA

View Full Version : password protect a directory?



laine
January 5th, 2001, 04:03
hi... i'm pretty new to cgi
is it possible to password protect a directory? i know there's this cgi script (lockedarea.com) where you can get a script and it would help you to do those .htaccess stuff...however i can't download the script now becos it's closed down... at least for sometime i have no idea how to do them becoss i don't use a telnet to upload my stuff to the server... i just use some ftp software

my page is on an NT server, digitalrice.com

is it very hard to password protect a directory?

neon
January 5th, 2001, 04:17
I have never used a NT server but I would guess it is the same when it comes to .htaccess files. You don't really need an outside script to make a .htaccess file as it is really easy to make. Here is a site that will explain the process and you should be able to make everthing you need and upload it to your server in like 10 mins. Anyway here is the site and hope it helps. Also if you need any help let me know and I will try to help you out.

http://www.echodev.com/tutorials/misc/htaccess/

Cheers,
Neon

laine
January 6th, 2001, 22:00
Hello, thanks for the tutorial link. it's really very useful, because the ones i managed to find were very hard! and this one was pretty easy!

hm, so i can only password protect a place where it gives you access to cgi? hm.

and i don't know why, for the .htpasswd file, the password doesn't need to be scrambled...strange strange

flin
January 28th, 2001, 10:28
I tried the password-generating script several times, each time using the same username and password. The username (in readable ASCII) remains the same, but different scrambled passwords come out. These results surprise me. I thought the same password should produce the same scrambled code. Am I wrong?

laine
January 28th, 2001, 20:26
strange
i have no idea about this
i only know in NT server passwords do not need to be scrambled, is that right? at least on the server i'm using the passwords are not scrambled

and i'd like to asssk if you put an .htaccess or .htpasswd on a server you can't delete or edit it am i right? becos i tried and it didn't work

LeX
January 29th, 2001, 06:32
I think they scramble the passwords automatically, you enter a normal password like "moo" and it'll get encrypted into something humans don't understand but recognizable by machines.

I edit all of my files on my HD (off-line), so I'm not sure wether or not you can edit the .htaccess file online. I'm not even sure if it'll show up or not.

Learned this from somewhere, forgot. Anyways, it looked real simple to create a .htaccess file.

Basically, you create a new file in Notepad or other simple text editor, save it as .htaccess using the "Save as Any file (*.*)" option, and it should work. Then you type this in the .htaccess file and save it:


ErrorDocument 400 /Bad.html
ErrorDocument 401 /Authorization.html
ErrorDocument 403 /Forbidden.html
ErrorDocument 404 /Missing.html
ErrorDocument 500 /Error.html

You don't have to write anything else. The file names can be renamed anything you want, I just labeled it so that I will know which file is for which error. :)
If you want, you can also place the error pages anywhere you want, like /error/Bad.html or /hehehe/Bad.html.

Then you create those pages, upload it, and you're done. May not work for some fwp, though, 'cause they don't support .htaccess files.

BTW, if you place the .htaccess file in your home directory (called the root), all subdirectories will also be affected, meaning that one .htaccess file in your root will also apply to other subdirectories, so accessing /yourroot/somesubdir/ will return the same error page as /yourroot/. Placing the .htaccess file in a subdirectory does not affect the root, only the subdirectory the file is in. Ex: uploading the file to /yourroot/somesubdir/ ONLY does not affect /yourroot/, so accessing /yourroot/ will return the default error page, whereas /yourroot/somesubdir/ will return your custom error pages. Understand?

All this I read from somewhere I've forgotten, maybe it was from http://www.perl.com or some text file, so if I'm wrong... well, tell me! :)

[Edited by LeX on 01-29-2001 at 07:40 AM]

laine
January 29th, 2001, 06:37
ahhh
the only problem is for me... um like i cannot edit or move the .htaccess/.htpasswd file now

after you've uploaded it
but i guess maybe we can if i use telnet
but i don't know how

...
now i see why people tell me to be-careful when using htaccess =]

LeX
January 29th, 2001, 06:47
use FTP

overwrite it

delete it

like I said, I don't think you can edit .htaccess files online, do it offline

laine
January 29th, 2001, 23:51
let me try overwriting it

haven't tried that! :) i hope hope hope it works