Home > Article > Backend Development > How to determine domain name jump in php
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.
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['HTTP_HOST']; if($url == 'www.web.cn'){ echo"<script>window.location.href='http://www.web.cn/web';</script><a href='http://www.web.cn/web'>如果系统长时间没有跳转界面请手动点击这里</a>"; }else if($url == 'www.bbs.cn'){ echo"<script>window.location.href='http://www.bbs.cn/bbs';</script><a href='http://www.bbs.cn/bbs'>如果系统长时间没有跳转界面请手动点击这里</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!