Home  >  Article  >  Backend Development  >  How to determine domain name jump in php

How to determine domain name jump in php

藏色散人
藏色散人Original
2021-12-02 10:07:283162browse

php method to determine domain name jump: 1. Create a PHP sample file; 2. Read the visiting domain name; 3. Through "if($url == 'www.web.cn'){. ..}" method to determine the domain name and jump to different pages.

How to determine domain name jump in php

The operating environment of this article: Windows 7 system, PHP version 7.4, DELL G3 computer

php How to determine domain name jump?

PHP reads the visiting domain name and determines to redirect to a different page

The code is as follows:

<?php
$url = $_SERVER[&#39;HTTP_HOST&#39;];
if($url == &#39;www.web.cn&#39;){
echo"<script>window.location.href=&#39;http://www.web.cn/web&#39;;</script><a href=&#39;http://www.web.cn/web&#39;>如果系统长时间没有跳转界面请手动点击这里</a>";
}else if($url == &#39;www.bbs.cn&#39;){
echo"<script>window.location.href=&#39;http://www.bbs.cn/bbs&#39;;</script><a href=&#39;http://www.bbs.cn/bbs&#39;>如果系统长时间没有跳转界面请手动点击这里</a>";
}else{
echo "地址错误";
}
?>

Recommended learning: "PHP Video Tutorial

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

Statement:
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