Home > Backend Development > PHP Problem > How to implement php domain name redirection

How to implement php domain name redirection

藏色散人
Release: 2023-03-17 12:32:01
Original
1111 people have browsed it

How to implement php domain name redirection: 1. Through "echo '' ;" Domain name redirection; 2. Domain name redirection is implemented through "header("Location:".$url);".

How to implement php domain name redirection

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

How to implement php domain name redirection?

Two ways to write domain name redirection in php

The first one

echo &#39;<meta http-equiv="Refresh" content="0;url=&#39; .  $url . &#39;">&#39; ;
Copy after login

The second one

header("Location:".$url);
Copy after login

Expansion introduction:

1.http-equiv=http response header

2.http-equiv and content attribute name/value pairs. When the server sends a document to the browser, it will first send these name/value pairs

3.

   <!--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=/">
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to implement php domain name redirection. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template