setting protecting

Discussion in 'Setting-up protection' started by amplidyne, Sep 21, 2008.

  1. amplidyne

    amplidyne New Member

    Joined:
    Sep 21, 2008
    Messages:
    3
    I have been trying to set up folder protecting for amember and read thru numerous thread but still don't have what I need.

    Here is what I am trying to accomplish.
    amember is installed in folder "members". This folder("members") then has three subfolders A,B an C and they contain protected information. When members sign up and log in to their accounts they are directed to members/member.php page which is defauly member home for amember. On this page, I have three links(I have added them to header.html so they are there on all amember pages) to folder A, B and C.

    I am using htpasswd method and each folder A, B and C has following .htaccess file. Folder A.B and C are protected in amember CP using htpasswd.

    Code:
    AuthType Basic
    AuthName "Members Only"
    AuthUserFile /vservers/user/htdocs/members/data/.htpasswd
    AuthGroupFile /vservers/user/htdocs/members/data/.htgroup
    Require valid-user
    
    Web site is a subscription based site and at this point one subscription gets you access to all the folders(A, B and C).

    My problem is that when users log in to their accounts and click on a link to folder A B or C, they are prompted again to enter their userid/password. What I need is to have them go directly to protected content(without second password) since they are already logged in to amember home.

    Is there a way to do it?

    Thanks for all your help.
    TBG
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Use htaccess protection instead of htpasswd. htpasswd will require a login for any new directory you try to go to.

    David
  3. amplidyne

    amplidyne New Member

    Joined:
    Sep 21, 2008
    Messages:
    3
    David,
    How do I do that?
    I have tried following.
    commented out these two lines in protection_methods.inc
    Code:
    //    elseif ($ret != '2-second_file')
    //    return "RewriteRule doesn't work in .htaccess files on this server";
    
    }
    this allow me to select new_rewrite from protection methods. I CHMOD(777) folders A B anc C and then select this protection method with "just any active subscription is enough". this add a .htaccess file in each folder(A,B anc C) withfollowing code
    Code:
    ########### AMEMBER START #####################
    Options +FollowSymLinks
    RewriteEngine On
    ## allow access for any active subscription
    RewriteCond %{HTTP_COOKIE} amember_nr=([a-zA-Z0-9]+)
    RewriteCond /vservers/user/htdocs/members/data/new_rewrite/%1 -f 
    
    RewriteRule ^(.*)$ - [L]
    ## if user is not authorized, redirect to login page
    # BrowserMatch "MSIE" force-no-vary
    RewriteCond %{QUERY_STRING} (.+)
    RewriteRule ^(.*)$ http://www.yourdomain.com/members/plugins/protect/new_rewrite/login.php?v=-any&url=%{REQUEST_URI}?%{QUERY_STRING} [L,R]
    RewriteRule ^(.*)$ http://www.yourdomain.com/members/plugins/protect/new_rewrite/login.php?v=-any&url=%{REQUEST_URI} [L,R]
    ########### AMEMBER FINISH ####################
    
    However, when I try to access protected folder, I get following error instead of login box.

    Code:
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, root@yourdomain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
    More information about this error may be available in the server error log.
    
    I am on a shared web hosting server.

    Thank you for all your help.
    TBG
  4. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Sounds like your server doesnt had mod_rewrite enabled. Ask them to enable it.

    David
  5. amplidyne

    amplidyne New Member

    Joined:
    Sep 21, 2008
    Messages:
    3
    Thanks David. You're correct. That's what I needed.

Share This Page