php域名转向的实现方法:1、通过“echo '<meta http-equiv="Refresh" content="0;url=' . $url . '">' ;”方式实现域名转向;2、通过“header("Location:".$url);”方式实现域名转向。

本教程操作环境:windows7系统、PHP8.1版、Dell G3电脑。

php域名转向怎么实现?

php的2种域名转向写法

第一种

echo '<meta http-equiv="Refresh" content="0;url=' .  $url . '">' ;

第二种

header("Location:".$url);

拓展介绍:

1.http-equiv=http响应头

2.http-equiv和content属性名称/值对,当服务器向浏览器发送文档时,会先发送这些名称/值对

3.<meta http-equiv="名" content="值">

   <!--1.禁止浏览器从本地机的缓存中调阅页面内容,设定后一旦离开网页就无法从Cache中再调出 -->
     <meta http-equiv="pragma" content="no-cache">
   <!--2.清除缓存(再访问这个网站要重新下载!)-->
     <meta http-equiv="cache-control" content="no-cache">
   <!--3.设定网页的到期时间,一旦网页过期,必须到服务器上重新传输。-->
     <meta http-equiv="expires" content="0">   
   <!--4.关键字,搜索引擎用-->
     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
   <!--5.页面描述-->
     <meta http-equiv="description" content="This is my page">
   <!--6.html+utf-8-->
     <meta http-equiv="content-type" content="text/html;charset=utf-8">
     <!--7.几秒后页面自动跳转-->
   <meta http-equiv="Refresh" content="2;URL=http://www.net.cn/">
     <!--8.Set-Cookie如果网页过期,那么存盘的cookie将被删除-->
     <meta http-equiv="Set-Cookie" content="cookievalue=xxx;expires=Wednesday, 20-Jun-200722:33:00 GMT; path=/">


php域名转向怎么实现