如何让用户的域名指向他们在我网站中的个人资料
我想通过让用户选择将其域名指向他们的个人资料来实现类似 Tumblr 或 Wordpress 的功能。例如,用户转到他们的域名注册商和我的服务器的 IP,那么: www.usersdomain.com 将指向 www.mysite.com/userid 而无需实际转发,以便域名仍将显示在地址栏中。
我希望您能详细描述这样做的步骤。
如果有什么区别的话,我正在使用 Ruby on Rails。我的生产环境有Nginx和Passenger。
I want to implement something like Tumblr or Wordpress by giving user the option to have their domain name point to their profiles. For instances user go to their domain registrar and the IP of my server so then: www.usersdomain.com will point to www.mysite.com/userid without actually forwarding so that domain name will still show in the address bar.
I wish you can describe the details for steps of doing so.
I'm using Ruby on Rails if that's make a difference. My production environment has Nginx and Passenger.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的观点:
Host
标头。该标头允许我们创建虚拟主机之类的东西:许多主机只能指向一个 IP;Host
并在数据库中查询具有此类主机的用户。例如,您的服务IP是100.100.100.100,我的域名是redsocks.com。我需要更改我的域的 DNS(A 记录)以指向您的 IP。据说,我做到了。
当我将浏览器指向我的域时,浏览器会向您自己的 IP,而不是我的 IP 发出以下请求(或类似请求):
您的应用程序具有处理我的请求的代码(伪代码):
并且我在我的域上查看您的服务中我自己的页面。
My point of view:
Host
header. That header allows us to make such thing as virtual hosting: many and many hosts can point to only one IP;Host
from the request and query your database for user with such host.For example, IP of your service is 100.100.100.100, my domain is redsocks.com. I need to change DNS (an A record) of my domain to point to your IP. Supposedly, I did.
When I point my browser to my domain, the browser makes the following request (or similar) to your own IP, not mine:
Your application has the code (pseudocode) that deals with my request:
And I see my very own page within your service on my domain.