Home > Backend Development > PHP Tutorial > php根据网址域名来路跳转的代码

php根据网址域名来路跳转的代码

WBOY
Release: 2016-06-20 13:04:35
Original
2226 people have browsed it

如何运用php根据网址域名来路判断跳转呢?

这里搜集下相关代码:

1、 问题要求:

根据来路分别跳转

根据输入域名跳转不同页面

PS:前提是不使用域名解析中的 URL转发!

实例: 访客输入:www.abc.com 访问根目录下 index.html访客输入:www.123.com 访问根目录下 main.html

可在原默认主页代码前加上如下判断语句

<p><?php   </p><p>$sUrl = $_SERVER['SERVER_NAME'];</p><p>if ($sUrl=="www.abc.com"){   </p><p>echo '<meta http-equiv="refresh" content="0; url=http://www.abc.com/index.html">';</p><p>}</p><p>if ($sUrl=="www.123.com"){   </p><p>echo '<meta http-equiv="refresh" content="0; url=http://www.123.com/main.html">';</p><p>}</p><p>?></p><p>
Copy after login

可根据自己实际要求来灵活变化语句!



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