能够使多域名但是只有一个站点的小站,通过路由访问到各个指定目录


<?php
//域名跳转路由
//默认跳转
$default = "http://www.stanwind.com/index.php";

//自定义域名路由
$routers = array(
	"so.stanwind.com" => "http://www.stanwind.com/zzss",
	"proxy.stanwind.com" => "http://www.stanwind.com/proxy",
	"json.stanwind.com" => "http://www.stanwind.com/json"
);

$currentHost = $_SERVER['HTTP_HOST'];
//echo $_SERVER['HTTP_HOST'];//获取当前域名 

$goPage = $default;
if (array_key_exists($currentHost, $routers)) {
	$goPage = $routers[$currentHost];
}

if (array_key_exists("QUERY_STRING", $_SERVER) && !empty($_SERVER["QUERY_STRING"])) {
	$goPage = $goPage.'?'.$_SERVER["QUERY_STRING"];
}
//echo $_SERVER["QUERY_STRING"];
//echo $goPage;
//重定向浏览器 
header("Location: ".$goPage); 
//确保重定向后,后续代码不会被执行 
exit;

相关文章:

  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2021-11-05
  • 2022-12-23
  • 2021-11-18
猜你喜欢
  • 2023-02-26
  • 2021-12-06
  • 2021-07-15
  • 2021-11-18
  • 2021-11-15
  • 2022-12-23
  • 2021-04-11
相关资源
相似解决方案