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

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

问题描述

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



问题是我希望我的域永远读取domain.com,所以我想让我的DNS重新映射到www.domain.com的任何请求到domain.com,我不能使用.htaccess或PHP或其他服务器方法,因为它只是一个博客界面。



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

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

哪些重定向www.domain.com到正确的网站,但www。仍然在域名上。我听说你可以做:

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

但我不知道我的注册商的内部IP地址可能会处理这个重定向(或者即使这样的事情实际存在)。 >

我可以要求完成吗?



谢谢你们摇滚。



-Josh

解决方案

不,你不能用DNS这样做 - DNS查询不会更改HTTP层中发生的情况,因此最初输入的域名将始终是发送到 Host:头文件中的Web服务器的域名。 p>

Web浏览器只查找DNS中的 A 记录,它是用户的ISP的递归名称服务器,它检测到名称实际上只有一个 CNAME 记录,然后它会查找,并在 CNAME 记录。



通常的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 Gurus:如何使用DNS将www.domain.com转发到domain.com?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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