嗨, friend 们,我的重定向页面 php 部分有一个问题。
这是我的 php 重定向部分:
<?php
session_start();
if (!(isset($_SESSION['uid']) && $_SESSION['uid'] != '')) {
header('Location: '.$base_url.'index.php');
exit;
}
include_once 'includes.php' ;
if($_GET['user_name']){
$user_name=$_GET['user_name'];
include_once 'public.php';
}
if(empty($_GET['user_name'])) {
header(location:$url404);
}?>
$url404"
位于includes.php
$url404=$base_url.'404.php';
问题是如果用户名为空,页面不会重定向
最佳答案
您忘记包含 "
,因此它不会将 header 视为字符串。
将 header(location:$url404);
更改为 header("Location:". $url404);
关于php header 位置未从 404 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26884368/