Redirect to domain "root" when not logged in

Discussion in 'Apache' started by moonpixel, Sep 12, 2013.

  1. #1
    Hi, I would like to do do following using basic authentication:
    1. non authenticated users have access to the index page: http://www.apple.com/
    2. there are other pages, e.g: http://www.apple.com/mac/ but these would require basic auth
    3. if users are not authenticated they would be redirected to http://www.apple.com/ otherwise authenticated users would have access to http://www.apple.com/ipod/ or anything else under that domain

    (http://www.apple.com/ is used just as an example it is not the actual URL :D, but the URL structure is same )

    I would really appreciate if anyone could suggest a solution for my problem.
    Many thanks
     
    moonpixel, Sep 12, 2013 IP
  2. JDR Hosting

    JDR Hosting Greenhorn

    Messages:
    1
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    23
    #2
    If you are using cookies for storing the login information, I assume the best way to do this is to verify for the existance of the auth cookie, and then process the login accordingly. Example: Auth cookie exists - access to all pages granted. Cookie does not exist - no access beyond the front page. For this to function, you would probably need some code in all pages that checks for the cookie.
     
    JDR Hosting, Sep 17, 2013 IP
    bumba1988 likes this.