将域名分配给不同的 URL

发布于 2024-12-11 16:25:20 字数 378 浏览 0 评论 0原文

我创建了一个网站构建器应用程序,网站访问者可以使用我的网站自行构建他们的网站。目前,每个站点 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风向决定发型 2024-12-18 16:25:20

www.newdomain.com 和(可能)newdomain.com 的 A 记录需要指向您的服务器(如果您还不知道/知道这是什么)意思是,我认为您至少阅读一下 DNS 的工作原理是很重要的)。那么你有两个选择:

  • 可以说更好、更常用的方法是在你的 Web 服务器上使用虚拟主机(类似于 Apache 的 mod_vhost_alias),并以这样的方式配置服务器,当它收到给定域的请求时,它会提供正确的文件 - 从您的 URL 方案的外观来看目前可行,如果不彻底改变你的架构,这将是一个不太简单的任务,你需要知道你在做什么。
  • 您可以检查用于从 PHP 中访问站点的域(使用 $_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:

  • Arguably the better and more commonly used approach is to use virtual hosting on your web server (with something like Apache's mod_vhost_alias), and configure the server in such a way that when it receives a request for a given domain, it serves the correct files - from the look of the way your URL scheme currently works, this would be a less than simple task without drastically changing your architecture, and you would need to know what you were doing.
  • You can check the domain that was used to access the site from within PHP (using $_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).
扬花落满肩 2024-12-18 16:25:20

这实际上取决于您拥有哪种类型的托管设置。每当我看到这种情况(您希望将域直接映射到路径而不使用任何类型的重定向)时,通常需要由主机后端通过手动调整设置来处理。

例如,用户如何获得自己的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文