脚本:
https://example.com/docs/index.php
在index.php中,我有以下代码:
header('Location: page2.php');
但是,不打开page2.php,而是打开以下URL:
https://example.com/docs/index.php/page2.php
如果我输入绝对网址,一切正常。
答案 0 :(得分:1)
<?php
/* Redirect to a different page in the current directory that was requested */
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'mypage.php';
header("Location: http://$host$uri/$extra");
exit;
?>