header() 函数

适用于 php,规范语法。

<?php 
header('location:https://hxx.tw', TRUE, 301); 
exit(); 
?>

语法:

header(string,replace,http_response_code)
参数 描述
string 必需。规定要发送的报头字符串。
replace 可选。指示该报头是否替换之前的报头,或添加第二个报头。默认是 true(替换)。false(允许相同类型的多个报头)。
http_response_code 可选。把 HTTP 响应代码强制为指定的值。(PHP 4 以及更高版本可用)

以下为 php 常见的简洁写法,但不规范。

<?php header('location:https://hxx.tw'); ?>

meta 标签

适用于 php 和 html

<meta http-equiv="refresh" content="0;url=https://hxx.tw">

script 标签

适用于 php 和 html

<script>window.location.href="https://hxx.tw"</script>

友情提示:本站所有文章,如无特殊说明或标注,均为何星星原创发布。与此同时,趋于近年来本站的文章内容频繁被他站盗用与机器采集,现已全局禁用网站文字内容操作,了解详情或转载文章请 点此 继续!
分类: 技术维新

0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用*标注