将域名分配给不同的 URL
我创建了一个网站构建器应用程序,网站访问者可以使用我的网站自行构建他们的网站。目前,每个站点 url 都是这样的:
www.sitebuilder.com/sites/site_id=18
我想要的是使每个用户都能够拥有其站点的真实域。例如,如果 site_id=18
的用户想要一个新域名:
www.newdomain.com
那么 www.newdomain.com
应显示 www.sitebuilder.com 的内容/sites/site_id=18
但不应该通过转发来完成。关于如何做有什么想法吗?
I have created a site builder application, where site visitors can build their websites on their own using my site. Currently, each site url is like this:
www.sitebuilder.com/sites/site_id=18
What I want is to enable each user to have a real domain for their site. For example, if the user with site_id=18
wants a new domain name as:
www.newdomain.com
Then www.newdomain.com
should show the content of www.sitebuilder.com/sites/site_id=18
But it should not be done by forwarding. Any ideas on how to do it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
www.newdomain.com
和(可能)newdomain.com
的 A 记录需要指向您的服务器(如果您还不知道/知道这是什么)意思是,我认为您至少阅读一下 DNS 的工作原理是很重要的)。那么你有两个选择:$_SERVER['HTTP_HOST']
),并据此提供正确的文件。这可能更容易设置,但我个人认为从长远来看它不太可持续 - 这是我个人的观点和 YMMV,这是一个可能会争论几个小时的主题(尽管 SO 不是这个地方)辩论)。The A records for
www.newdomain.com
and (probably)newdomain.com
would need to be pointed your server (if you don't know this already/know what this means, I think it's important you do at least a little reading on how DNS works). Then you have two options:$_SERVER['HTTP_HOST']
), and serve the correct files based on this. This would probably be simpler to set up, but I personally would consider it less sustainable in the long term - this is my personal opinion and YMMV, it is a subject that could probably be debated for hours (although SO is not the place for that debate).这实际上取决于您拥有哪种类型的托管设置。每当我看到这种情况(您希望将域直接映射到路径而不使用任何类型的重定向)时,通常需要由主机后端通过手动调整设置来处理。
例如,用户如何获得自己的 URL?显然,他们不会去 GoDaddy 购买自己的服务 - 您可能将其作为服务提供,并自行处理注册商的事务。
不想这么说,但每当用户购买域名时,您可能只需要手动将域名映射到服务器空间上的正确文件夹即可。我确信域流程目前还不是 100% 自动化,那么这里那里额外花 5 分钟的工作有什么意义呢?只需设置一个脚本,当有人为域名付费时,它会向您发送一封电子邮件,提醒您进行必要的后端更改。然后告诉用户,更改最初需要 24-48 小时才能实施。
It really depends on what kind of hosting setup you have. Anytime I've seen this (where you want a domain mapped directly to a path and NOT use a redirect of any kind) that needs to be handled by the backend of the host usually through manual adjustment of the settings.
For example, how does a user even get their own URL? Obviously they won't go to GoDaddy and buy their own – you probably offer it as a service and take care of the registrar stuff on your own.
Hate to say it, but you may just have to manually map a domain to the correct folder on the server space whenever a user purchases one. I'm sure that domain process isn't 100% automated currently, so what's an extra 5 minutes of work here and there? Just setup a script that'll shoot you an email when someone pays for a domain that reminds you to make the necessary backend changes. And then tell a user and change will take 24-48 hours to implement initially.