Jump to content

Password Protect Directories - Is It Possible?


Recommended Posts

It sounds simple enough, but I haven't been able to execute it. When someone attempts to access a directory in the domain, instead of finding a permissions error, I'd like authorized users to be able to enter a user name and password to view the contents of that directory. Yet, and here's the big finale, I'd still like the contents of that directory to be viewed as embedded content in pages for those who are NOT authorized.

 

Is something like this possible, or am I dreaming of a happier, simpler time when summer days were long and ice cream sundays were as big as a house...

 

Thanks,

Dean

Link to post
Share on other sites

Welcome to the forum fiberse :blink:

 

I know you can protect a directory in cpanel,

but without the passowrd, they weill see a not authorized to view this directory.

 

Not sure what you mean by

I'd still like the contents of that directory to be viewed as embedded content in pages for those who are NOT authorized.
Link to post
Share on other sites

I think I understand.

 

Say I have PhotoABC.jpg, and it's in folder XYZ that contains photos I'd like to password protect. I add password protection, and that's dandy.

 

What if I want PhotoABC.jpg to appear on my blog without a password prompt or a big red X? Only photograph in the directory that I want to show but it's part of a set or somesuch, so it isn't worth my time creating a new directory just for it alone.

 

I think thats what fiberse wants.

Edited by marie b.
Link to post
Share on other sites
Welcome to the forum fiberse  :)

 

I know you can protect a directory in cpanel,

but without the passowrd, they weill see a not authorized to view this directory.

 

Not sure what you mean by

 

Hello Don,

 

Marie was pretty on-target. In short, I would like those working with me to be able to access a directory on the domain if they have the Username and Password. By doing so, they should be able to browse the directory, it's contents and any sub-directories. Yet, the images in this directory are used as graphics in web pages, and I would still like those graphics to be displayed within web pages to the general public. I don't know if such an arrangement is possible, but my main goal is to block outsiders from viewing the contents of a particular directory, but still allow verified access to the same directory to those who need to view its contents as part of their daily business routine - but the graphics contained within should display on web pages for all to see...

 

Any thoughts?

 

Thanks so much for any and all advise you are able to impart, it is much appreciated.

 

Dean

 

Thank you to everyone for your warm welcome!

Link to post
Share on other sites

If you "password protect" a directory such as photos does it stop it from people viewing it on your webpages directly?

 

I guess I am asking WHAT password protecting a directory really acomplishes, as it might help me with the issues I am having with one person.

Link to post
Share on other sites

From my own experience, all pages within a passworded directory will be protected. So no matter if you try to access one of those pages directly within the directory you will be asked for the log in info.

Link to post
Share on other sites

If you use htaccess/htpasswd to password protect a directory, then any attempted access to the file will prompt for a username/password, even if it's just an image embedded in another page somewhere.

 

What you could do is, assuming you have an index file for the directory, use a simple password script on the index before you're allowed to view the images/etc. Since the index file is what's loaded when a user enters a directory name, this would theoretically work... Then, to get a directroy listing, you'd just have to make the index.html/.php (probably php if you're doing password protection) file a directory list with links to every file.

 

The reason you can't use htaccess/htpasswd passwording to only prevent directory listing is because they assume you only want authorized people to view the folder's contents. If you link the images somewhere, people could just click the link and see the file (if it didn't protect everything in the directory).

 

So yeah, that's a long way of saying that, as far as I know, you can't do exactly what you want, but you can do something that could work.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...