创建编程子域 [英] Creating Subdomains Programmatically

查看:200
本文介绍了创建编程子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个解决方案来创建子域编程在ASP.NET,ASP.NET MVC和PHP。具体而言,用户的个人资料页应解析为: www.domain.com/profilename http://profilename.domain.com

I am looking for a solution to create subdomains programmatically in ASP.NET, ASP.NET MVC and PHP. Specifically, a user profile page should resolve for both: www.domain.com/profilename or http://profilename.domain.com .

推荐答案

更​​新,以便在特定域的DNS设置* .domain.com都指向同一主机。

Update your DNS settings of the particular domain so that *.domain.com all point to the same host.

然后,以编程方式检查,看看是否使用的URL的第一部分包含您正在寻找的子域,并采取相应的行动。例如,如果第一部分包含一个给定的profilename,然后检索数据的该特定配置文件收集从你的数据库并显示给用户。

Then, programmatically check and see if the first part of the URL used contains the subdomain you are looking for, and act accordingly. For example, if the first part contains a given profilename, then retrieve that particular profiles collection of data from your DB and display it to the user.

请确保您的Web应用程序使用相对链接,这样,如果在现场使用的子域,你不重定向到其他地方的用户到达。

Make sure your web application uses relative links, so that if the user arrives at the site using a subdomain, that you don't redirect them elsewhere.

这篇关于创建编程子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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