The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Password protected directories

Discussion in 'Security' started by stars, Dec 31, 2012.

  1. stars

    stars Member

    Joined:
    Oct 2, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    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.
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,463
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    It might be wordpress interfering with this. Is client-345 an actual directory or a category in your wordpress?
     
  3. stars

    stars Member

    Joined:
    Oct 2, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    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
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,463
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    You might find the wordpress site more helpful for this sort of thing.
    /http://wordpress.org/support/topic/plugin-nextgen-gallery-password-protect-an-album
     
  5. stars

    stars Member

    Joined:
    Oct 2, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    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.
     
  6. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,463
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    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.

    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?
     
  7. stars

    stars Member

    Joined:
    Oct 2, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    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.
     
    #7 stars, Jan 1, 2013
    Last edited: Jan 1, 2013
  8. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,463
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.

    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.
     
  9. stars

    stars Member

    Joined:
    Oct 2, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    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?
     
  10. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,463
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    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.
     
  11. stars

    stars Member

    Joined:
    Oct 2, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    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.
     
  12. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page