成功登录重定向到登录页面

时间:2017-12-22 02:31:09

标签: php login

成功登录后,我被重定向到登录页面。请在wamp和post方法loginaction.php中找到以下vhost设置代码。

<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www/aklc_portal/admin"
  <Directory "${INSTALL_DIR}/www/aklc_portal/admin">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

POST方法loginaction.php

分别尝试这三个:

$refererURL =$_SERVER["HTTP_REFERER"];
$refererURL ="/index.php";
$refererURL ="http://localhost/aklc_portal/admin/index.php";

if (isset($_POST['username']) && isset($_POST['password']))
  {
     //check DB
     //set cookie
  }

 else {
     //other logic. New reffererURL
}

//redirect

header("Location: ".$refererURL);

1 个答案:

答案 0 :(得分:0)

删除或评论

$refererURL =$_SERVER["HTTP_REFERER"]

$refererURL ="http://localhost/aklc_portal/admin/index.php";

因为您的根目录是aklc_portal / admin /,您只需要指向索引,第三个$refererURL将覆盖第一个和第二个