DNS 大师:如何仅使用 DNS 将 www.domain.com 转发到 domain.com? [英] DNS Gurus: How to forward www.domain.com to domain.com using DNS only?

查看:20
本文介绍了DNS 大师:如何仅使用 DNS 将 www.domain.com 转发到 domain.com?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 posterous.com 上运行一个博客,如果我在我的域注册商的自定义 DNS 工具中为他们的 IP 创建 A 记录,他们可以托管我的域名.

问题是我希望我的域始终读取 domain.com,所以我希望我的 DNS 将所有对 www.domain.com 的请求重新映射到 domain.com,并且我不能使用 .htaccess 或 PHP 或其他服务器方法,因为它只是一个博客接口.

到目前为止,我已经尝试过:

<前>@一个target.ip.addresswww CNAME domain.com

将 www.domain.com 重定向到正确的站点,但 www.仍在域中.我听说你可以这样做:

<前>@一个target.ip.addresswww 一个 internal.redirector.ip.address

但我不知道我的注册商的内部 IP 地址可以处理此重定向(或者即使这样的事情确实存在).

我的要求能完成吗?

谢谢,你们摇滚.

-乔希

解决方案

不,你不能用 DNS 做到这一点——DNS 查询的结果不会改变 HTTP 层发生的事情,所以最初输入的域名将始终是在 Host: 标头中发送到 Web 服务器的那个.

Web 浏览器只在 DNS 中查找 A 记录,并且是用户的 ISP 的递归名称服务器检测到该名称实际上只有一个 CNAME 记录,它然后查找,并在CNAME记录中返回与该名称对应的IP地址.

通常的 C gethostbyname() API 不会将任何 CNAME 信息返回给应用程序,它所获得的只是最终生成的 IP 地址.>

要实现您想要的效果,您需要安排 www.example.com 与您的博客分开托管,然后让该站点执行 HTTP 重定向到 example.com(即没有 www 前缀)

I am running a blog at posterous.com, and they can host my domain name if I create an A record to their IP in my domain registrar's custom DNS tool.

The problem is that I want my domain to ALWAYS read domain.com, so I want to have my DNS remap any requests to www.domain.com to domain.com, and I can't use .htaccess or PHP or other server methods, since it's just a blog interface.

So far, I've tried:

@ A target.ip.address
www CNAME domain.com

Which redirects www.domain.com to the right site, but the www. is still on the domain. I heard you could do:

@ A target.ip.address
www A internal.redirector.ip.address

but I don't know my registrar's internal IP address that might handle this redirection (or even if such a thing actually exists).

Can what I'm asking for be done?

Thanks, you guys rock.

-Josh

解决方案

No, you can't do this with DNS - the result of the DNS query doesn't change what happens in the HTTP layer so the originally entered domain name will always be the one that's sent to the web server in the Host: header.

Web browsers only look up A records in the DNS, and it's the user's ISP's recursive name server which detects that the name actually only has a CNAME record, which it then looks up, and returns the IP address corresponding to that name in the CNAME record.

The usual C gethostbyname() API doesn't return any of that CNAME information to the application, all it ever gets is the final resulting IP address.

To achieve what you want you'd need to arrange for www.example.com to have separate hosting from your blog, and then have that site do an HTTP redirect to example.com (i.e. without the www prefix)

这篇关于DNS 大师:如何仅使用 DNS 将 www.domain.com 转发到 domain.com?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆