
php如何利用header实现跳转,下面web建站小编给大家详细介绍一下!
浏览器重定跳转
<?php
//重定向浏览器
header("Location: https://ipkd.cn");
exit;
?>
浏览器重定跳转
<?php
//重定向浏览器
header("Location: https://ipkd.cn");
exit;
?>
404跳转
function getref()
{
$url = @$_SERVER['HTTP_REFERER'];
if( !empty( $url ) )
{
if( !strstr($url ,'jb51.net' ) && !strstr($url,'jb51.net'))
{
@header("http/1.1 404 not found");
@header("status: 404 not found");
include("404.html");//404页面
exit();
}
}
else
{
@header("http/1.1 404 not found");
@header("status: 404 not found");
include("404.html");//404页面
exit();
}
}
301跳转
<?php
$the_host = $_SERVER['HTTP_HOST'];
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
if($the_host !== 'www.jb51.net')
{
//echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://www.jb51.net' . $_SERVER['PHP_SELF'] . $request_uri);
}
?>
上面是“php如何利用header实现跳转”的全面内容,想了解更多关于 php入门 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2865.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

一款由谷歌公司推出的 AI 求职工具——Career Dreamer
免费商用中文字体——优设鲨鱼菲特健康体
喵记多APP最新版