www.abc.com、services.abc.com、support.abc.com。services、support(www 用根目錄)。default.aspx。Global.asax 實作 Application_BeginRequest:protected void Application_BeginRequest(object sender, EventArgs e)
{
string host = Request.Url.Host;
int i = host.IndexOf('.');
if (i > 0)
{
string subDomain = host.Substring(0, i); // 取第一個點前段
if (subDomain != "www")
{
HttpContext.Current.RewritePath("~/" + subDomain + Request.Url.PathAndQuery);
}
}
}
RewritePath 內部重寫請求路徑,瀏覽器網址列保持 services.abc.com/xxx,實際執行 /services/xxx 下的頁面。
此技巧為中小型多品牌/多部門站點部署的經典低成本方案。