Results 1 to 6 of 6
  1. #1

    Redirect to different page, using htaccess

    I have password protected folders, using htaccess... in the file there are many users, that can enter the folder... The issue is: I want to redirect the user, depending on his username, to his own page... HOWTO???

  2. #2
    Join Date
    Oct 2001
    Location
    Mountain Home Arkansas
    Posts
    131
    PHP has a predifinded variable that will return the username based on your .htaccess user list.

    $_SERVER['PHP_AUTH_USER']

    http://us3.php.net/features.http-auth
    rocket science is more fun when you accually have rockets!

  3. #3
    So how do I use it? For example - I have login page, on the index page /home page/ - then the user types his username and password.. how do I redirect him to his own page?

  4. #4
    Join Date
    Oct 2004
    Location
    UK
    Posts
    487
    You dont have to redirect them to their own page, you redirect them to one page for all of them, but change the information or the MySQL query based on the username entered, ie: Using $_SERVER['PHP_AUTH_USER']

  5. #5
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,738
    You could do something like this:

    Members folder is :http://yoursite.com/members/
    Each user could have something like: http://yoursite.com/members/user1

    So when they log in using .htaccess to http://yoursite.com/members/
    on the index.php page of that you could have something such as:

    PHP Code:
    if(isset($_SERVER['PHP_AUTH_USER'])) {
    header("Location: http://yoursite.com/members/".$_SERVER['PHP_AUTH_USER']);
    }
    else 
    header("Location: http://yoursite.com/unauthorized.php"); 
    Hope this helps.
    <<< Please see Forum Guidelines for signature setup. >>>

  6. #6
    Great help it was, indeed
    Let the Power be with you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •