1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Redirect via .htaccess

Discussion in 'PHP' started by qwikad.com, Jul 21, 2024.

  1. #1
    So right now I'm redirecting like so:

    if ($login == "Success") {
     
    echo '<script>location.href = "user_account.php";</script>';
    
    }else{
    
    $err = "some error";
    
    }
    Code (markup):
    It's sluggish. Takes a couple seconds. I did an html redirect via the header, same thing - sluggish.

    I'd like redirect from login.php (once a user is logged in) to user_account.php via .htaccess. How do I do that? I know how to do a redirect from one file to another, but how do I do the same only after a successful login?


    .
     
    qwikad.com, Jul 21, 2024 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    29,152
    Likes Received:
    4,621
    Best Answers:
    124
    Trophy Points:
    665
    #2
    Your logic should be at the top of the script before you output anything which means you can use header()
    ref: https://www.php.net/manual/en/function.header.php

    if ($login == "Success") {
       header('Location: https://mysite.com/user_account.php');
       exit;
    } else {
       $err = "some error";
    }
    PHP:
     
    sarahk, Jul 21, 2024 IP
    qwikad.com likes this.