允许在Web应用程序项目中使用自定义域名 [英] Allowing the usage of custom domain names for web application projects

查看:201
本文介绍了允许在Web应用程序项目中使用自定义域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在创建Web应用程序时启用自定义域的最佳方式。例如,如果您看到像Base Camp这样的东西,当您注册时,您将创建自己的子域,您可以使用它们登录到您的basecamp。

I would like to know the best way to enable custom domains when creating web applications. For instance, if you look at something like Base Camp, when you sign up for that you create your own 'sub domain' to which you use to login to your basecamp with.

另外,如果您看到这样的托管电子商务网站,您可以使用自己的自定义域名,而不是使用他们的子域名。

Also, if you look at this like hosted ecommerce sites, you can use your own custom domain instead of using a sub domain of theirs.

我个人不能看到这些网络应用程序停放在网络应用程序主机帐户上的每个自定义域名,如果使用像Base Camp这样的子域,则添加DNS。

Personally I can't see these web applications 'parking' each custom domain on the web apps hosting account or adding the DNS if it uses a sub domain like Base Camp does.

因此,唯一的方式我可以考虑像这样动态地做一些动作,可能是使用mod_rewrite将所有内容重定向到基于URL的路由的某个脚本。然后,对于客户域,客户只需要为自己的域添加一个CNAME,如custom.webappname.com,然后又被mod_rewrite和php路由文件提取。

Therefore, the only way I can think about doing something dynamically like this is to maybe use mod_rewrite to redirect everything to a certain script that does the 'routing' based on the url. Then for the customer domains, the customer would just need to add a CNAME for their domain to something like custom.webappname.com which then in turn gets picked up by mod_rewrite and the php routing file.

如果这是最好的方法,有没有通过这个路由文件路由所有传入请求的性能问题?

If this is the best way forward, are there any performance issues with routing all incoming requests via this 'routing file'?

对不起,如果不是清楚,试图解释最好的我可以。

Sorry if im not clear, tried to explain the best I can.

推荐答案

你有正确的想法。您保留单个代码库,在单个IP上运行(为了参数)。您不需要担心虚拟主机,甚至是mod_rewrite(除了您的应用程序需要之外)。

You've got the right idea. You keep a single codebase, running (for the sake of argument) on a single IP. You don't need to worry about virtual hosts, or even mod_rewrite (aside from whatever your application needs).

您的Web应用程序只需处理对该IP的任何和所有请求(80或443端口,或任何)。

You web app simply handles any and all requests to that IP (on port 80 or 443, or whatever).

当您的应用程序引导响应请求时,它会窥视$ _SERVER ['HTTP_HOST'],并为与该域名关联的客户端配置自身。如果没有找到,它404s,或任何最有意义的。

When your application bootstraps in response to a request, it peeks at $_SERVER['HTTP_HOST'], and configures itself for the client associated with that domain name. If not found, it 404s, or whatever makes the most sense.

这篇关于允许在Web应用程序项目中使用自定义域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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