php中输入这个网站的网址跳转到你定义的页面代码

代码很简单,涉及到header函数的使用,代码如下 

 1 <?php
 2     if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
 3         $uri = 'https://';
 4     } else {
 5         $uri = 'http://';
 6     }
 7     $uri .= $_SERVER['HTTP_HOST'];
 8     header('Location: '.$uri.'/demo/');
 9     exit;
10 ?>

代码解释 :我先判断一下你是否开启了https,如果是就正常的https页面,如果没有开始则跳转到项目的目录下面

原文地址:https://www.cnblogs.com/58top/p/2980349.html