CNAME正在重定向到我的主页

时间:2018-05-02 22:11:03

标签: dns cname centos-web-panel

我在以下路径上托管了一个网站:mywebsite.com/test,其中包含以下DNS

mywebsite.com            A   1.2.3.4 (host ip)
host.mywebsite.com       A   1.2.3.4 (host ip)

在另一个域上,我尝试使用以下内容将子域CNAME重定向到此页面:

link.myotherdomain.com   CNAME .  mywebsite.com/test

但是,当我访问link.myotherdomain.com时,它会显示host.mywebsite.com而不是mywebsite.com

我做错了什么?

由于

1 个答案:

答案 0 :(得分:1)

CNAME记录不能包含路径。它只适用于域名。 此设置将起作用。

link.myotherdomain.com.   CNAME   mywebsite.com.

如果配置正确,mywebsite.com host.mywebsite.com link.myotherdomain.com的所有内容都将解析为1.2.3.4,则会将以下HTTP请求发送到IP地址1.2.3.4。< / p>

GET /test HTTP/1.1
Host: link.myotherdomain.com
......(omit)

现在,最可疑的元素是网络服务器的虚拟主机设置。 这是Web服务器的一个功能,根据请求标头中的Host值,它的行为就好像它是一个不同的服务器。

要调查虚拟主机,以下可能是最简单的方法。

  • curl -H 'Host:mywebsite.com' http://1.2.3.4/test //这没关系
  • curl -H 'Host:link.myotherdomain.com' http://1.2.3.4/test //如果启用虚拟主机
  • ,则无效
相关问题