DNS 文件映射
我正在尝试开发一个 Web 应用程序的功能,但此时我有点困惑。我想知道是否有人可以阐明以下场景。
假设我的 Web 应用程序位于 domain1.com,用户网站位于 domain2.com。我希望允许用户能够将其域映射到我的服务器上的文件/页面之一。因此,如果有人访问domain2.com/files,那么它将在内部透明地路由到domain1.com/files.aspx?domain=2(注意域参数)。
我知道这可以通过用户服务器上的简单文件重定向(301 或 302)来完成,但我想在 DNS 级别上实现这一点。我该怎么办呢?
提前致谢!
I'm trying to work out a feature for a Web application, but I'm a bit confused at this point. I was wondering if anyone can shed some light on the following scenario.
Say, my Web app is located at domain1.com and a users website is located at domain2.com. What I would like to allow is for the user to be able to map their domain to one of the files/pages on my server. So if someone accesses domain2.com/files then it will internally and transparently route to domain1.com/files.aspx?domain=2 (notice the domain parameter).
I know this can be done with a simple file redirection (301 or 302) on the users server, but I would like to achieve this on the DNS level. How can I go about it?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 A 记录将domain2.com(或子域)映射到运行domain1.com 的同一IP。这就是您在 DNS 级别上可以实现的所有内容,因为它不关心目录结构。
You can map domain2.com (or a subdomain) to the same IP domain1.com runs on using the A record. That's about everything you can achieve on DNS level, as it doesn't care about directory structures.
简而言之,你不能。如果您想将
foo.domain1.com
指向foo.domain2.com
的记录,那么您可以使用CNAME
记录,但 DNS 不知道 HTTP URL。Simply put, you can't. If you wanted to point
foo.domain1.com
to the record forfoo.domain2.com
, then you can probably use aCNAME
record but DNS has no clue about HTTP URLs.如果您将 Simple DNS Plus 的“HTTP 重定向器”插件配置为重定向到“http://domain1.com/files.aspx?domain=#HOST#"
从技术上讲,它实际上执行 HTTP 重定向(本地 DNS 是不可能的),但它是在 DNS 服务器上完成的,而不是在 DNS 服务器上完成的。网络服务器。
请参阅http://www.simpledns.com/kb.aspx?kbid=1258
The "HTTP Redirector" plug-in for Simple DNS Plus does just that if you configure it to redirect to "http://domain1.com/files.aspx?domain=#HOST#"
Technically it actually does a HTTP redirect (native DNS is not possible), but it is done at the DNS servers instead of the web-server.
See http://www.simpledns.com/kb.aspx?kbid=1258