I have a link in my dashboad
page( http://localhost/dashboard.php
). The link is as following:
<a class="nav-link" href="logout.php">
<img class="icon mb-n1px" src="assets/icons/sign_out.svg" alt="category icon">
Log Out
</a>
In the logout.php
file, I have the following code:
<?php
session_unset();
header("Location: /");
exit();
?>
So clicking on that link the user agent is redirected to http://localhost/
. I want to redirect to http://localhost
without the trailing slash. My question is
header("Location: ");
not work?header("Location: ../");
still lead to http://localhost/
.header("Location: /../");
doesn't remove the trailing slash?PS: I have read the official docs https://www.php.net/manual/en/function.header.php and other SO posts but didn't find any explanation.
You can use absolute url header("Location: http://localhost");
http://localhost
and http://localhost/
are equal/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.