• 1
  • 2
  • 3
  • 4
  • 5
阿里云主机ECS 首 页  »  帮助中心  »  云服务器  »  阿里云主机ECS
多域名跳转——不同域名指向不同子目录使用PHP程序实现的方法
发布日期:2016-1-11 18:1:38

  介绍多域名跳转——不同域名指向不同子目录,使用PHP程序实现的方法:

  测试网站目录结构:

  

  测试代码:

  

  实现的效果是:

  将3个域名解析到一个IP地址上,通过index.php进行判断,自动跳转到对应的子目录。

  使用a.example.com访问自动跳转到a.example.com/a/index.html

  使用b.example.com访问自动跳转到b.example.com/b/index.html

  使用c.example.com访问自动跳转到c.example.com/c/index.html

  若域名都没有匹配到,自动跳转到other.htm