多个一级域名如何在一个阿里云的虚拟空间建多个网站

EightPoint
EightPoint
管理员
45
文章
0
粉丝
数智软件评论105阅读模式


2个以上一级域名如何访问同一个虚拟空间,我们可以在网站1根目录下的index.php里加入以下代码,然后建议网站2目录,如下:

 文章源自八点运动-https://www.8oio.com/53.html

<?php文章源自八点运动-https://www.8oio.com/53.html

switch ($_SERVER["HTTP_HOST"])文章源自八点运动-https://www.8oio.com/53.html

{文章源自八点运动-https://www.8oio.com/53.html

case "网站2域名":文章源自八点运动-https://www.8oio.com/53.html

case "网站2域名":文章源自八点运动-https://www.8oio.com/53.html

header("location:./网站2目录/index.php");文章源自八点运动-https://www.8oio.com/53.html

break;文章源自八点运动-https://www.8oio.com/53.html

case "网站1域名":
case "网站1域名":文章源自八点运动-https://www.8oio.com/53.html

//以下为原网站内容
header("Content-type: text/html; charset=utf-8");文章源自八点运动-https://www.8oio.com/53.html

break;
}
?>

 

仅限PHP

 最后更新:2025-2-25
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证