Password protected directories

stars

Member
Oct 2, 2012
9
0
1
cPanel Access Level
Website Owner
I did password protect a directory via cPanel.

When I enter the protected directory URL or a file located in this directory into the browser, I receive a 404 page instead to get prompted to enter a user name and password.

http://www.my-domain-name.com/wp/wp-content/client-345/
http://www.my-domain-name.com/wp/wp-content/client-345/image.jpg

cPanel generated this .htaccess file:
AuthUserFile "/home/.../.htpasswds/public_html/wp/wp-content/client-345/passwd"
AuthName "ano789"
AuthType Basic
require valid-user

Any help to access the protected directory via browser would be appreciated.
 

stars

Member
Oct 2, 2012
9
0
1
cPanel Access Level
Website Owner
Client-345 is the name of a directory located in the wp-content directory. It contains a private gallery/slideshow (i.e wedding photography). They client should be able to access this directory with a username and password to view the images and order prints.

…/wp/wp-content/client-345
…/wp/wp-content/client-346
…/wp/wp-content/client-347
 

stars

Member
Oct 2, 2012
9
0
1
cPanel Access Level
Website Owner
I work a lot with the nextgen-gallery plugin, but not for password-protected albums, since images are not really protected in the directories.

We have to make sure, only persons with the correct credentials have access to this directory carrying private/confidential image-files.

In this particular case/website, the photographer wishes to upload galleries exported from lightroom or bridge to the client folder.

... And right now we did not upload any gallery yet, since we need to get the access issue fixed first.

The Wordpress blog with nextgen-galleries shows off public work of the artist. The images are sized and watermarked appropriately to avoid any misuse.
 

Infopro

Well-Known Member
May 20, 2003
17,075
524
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
Still, I don't see the issue with your cPanel account. Additional details on what you're doing with your site has no bearing on the matter of trying to pass protect a directory inside a wordpress.

... And right now we did not upload any gallery yet, since we need to get the access issue fixed first.
Create another directory here instead: public_html/client-345Tester/

Password protect that one, it's empty just like your other directory.

Are you able to password protect that from within your cPanel?
 

stars

Member
Oct 2, 2012
9
0
1
cPanel Access Level
Website Owner
I did protect the directory "…/wp/wp-content/client-345" via cPanel successfully.

cPanel wrote into the .htaccess file of this directory:

AuthUserFile "/home/.../.htpasswds/public_html/wp/wp-content/client-345/passwd"
AuthName "ano789"
AuthType Basic
require valid-user

The problem is, I can't access the directory via browser, a 404 page shows up instead to get prompted to enter a user name and password, when I call the URL of a test-image located in the directory.

I can't place the client directory into the root of the website, since the WP installation is done in a sub-directory ".../wp/", and all directories have to be located there in order to be accessed through the website-URL in a browser.
 
Last edited:

Infopro

Well-Known Member
May 20, 2003
17,075
524
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
I did protect the directory "…/wp/wp-content/client-345" via cPanel successfully.
So this part of this, works. There is no issue with your cPanel being able to lock down the directory. The issue then is with your wordpress.

I can't place the client directory into the root of the website,
That's not what I was suggesting. It was meant to test to be sure cPanel is working as expected. A 404 error suggests the directory, or file, is not found at that location. But you know that the directory, and file, are there though. My guess, something in your wordpress is happening here.

If I access the uploads directory on a test wordpress installation: domain.com/wp-content/ I get a 404 error. No password protection added, I just tried to directly access that directory.

This is a wordpress issue. Sorry I can't help more.
 

stars

Member
Oct 2, 2012
9
0
1
cPanel Access Level
Website Owner
OK.

How can I access the directory as promised in cPanel, please see capture of the help video.

Capture.JPG

When I remove the directory password protection, the image will be displayed as usual, but when I add the password protection the 404 page shows and not the dialog to get prompted to enter a user name and password.

Maybe there is a different usage behind this cPanel functionality?
 

Infopro

Well-Known Member
May 20, 2003
17,075
524
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
The functionality of the cPanel Password Protection tool works as expected. Wordpress interfers with what you're hoping to accomplish. For a way around that, you'll need to ask your question on the wordpress support site. To try and assist you in some way, I did some digging and found this tip.

/http://codex.commons.gc.cuny.edu/password-protecting-individual-wordpress-pages-and-posts/

Give that a go and see if it helps.
 

stars

Member
Oct 2, 2012
9
0
1
cPanel Access Level
Website Owner
Thanks so much Infopro. I use this "Password Protecting Individual WP Pages and Posts" feature on a couple of sites, i.e. partner logins. It protects the post/page content stored in the database, but not the files in the directories.

I didn't know that WP interferes with this cPanel function. A possible work-around could be a blank sub-domain. The uploads are not WP related; they are self-driven galleries prepared by lightroom, and wouldn't need any additional apps, just a protected directory.
 

quietFinn

Well-Known Member
Feb 4, 2006
1,899
465
438
Finland
cPanel Access Level
Root Administrator