php根据域名访问不同跳转到不同子目录的方法
浏览量:562
//key-value 路由表 $domain_route = array( 'a.com'=> 'a/index.html', 'www.a.com'=> 'a/index.html', //处理www 'b.com'=> 'b/index.html', ); //获取当前访问域名做为:key $domain = $_SERVER['HTTP_HOST']; //通过key-value表取出目录地址 $target_url = $domain_route[$domain]; //能过header跳转至目录地址,注意,使用header跳转需要把此段代码放至你程序代码的开始处理,执行此代码代码前,不能有任何输出内容 header("location:{$target_url}");