Support » Fixing WordPress » Accessing password-protected domain folders w/out entering password

  • mcnb


    Am running WordPress 3.4.2 with Thesis theme and s2Member Pro (for user registration). Users are required to sign in before they can view almost anything beyond the cover photo and some links on a sidebar.

    I store nearly all of my photos as jpgs in a folder on my domain and link to the photos from my posts. In other words, the photos live outside of WordPress. I made this decision years ago for a variety of reasons.

    Now, I need to password protect (via my domain’s control panel) the directories containing photos. The primary purpose is to prevent them from being found by search engines, other reasons as well.

    If I simply put a password on the directory, each time a registered user wants to see a photo in a post, they have to enter the password to the domain directory. Is there a way for me to, for lack of a better word, embed the password somewhere within WordPress so that the WordPress blog can access all photos in the protected directories?

    Thank you for any guidance.

Viewing 1 replies (of 1 total)
  • michael.mariart


    The “standard” way to do this is to set up a PHP script that will check for a logged in user, then basically pipe the image file to the user. as a very quick and dirty example…

    if ($is_logged_in) {
        header ("Content-type: image/jpeg");
        echo file_get_contents ("/path/to/image.jpg");
        die ();

    Of course there’s a lot more to the authentication then that, but that’s about the best way to do it. This way you can have the images anywhere on your server/account that you can access so the public can’t access them.

Viewing 1 replies (of 1 total)
  • The topic ‘Accessing password-protected domain folders w/out entering password’ is closed to new replies.