开发者

MVC: how to correctly serve multiple domain names from one site (different content for each)

开发者 https://www.devze.com 2023-02-20 17:37 出处:网络
Hoping there\'s been a \"best practices\" way to accomplish this so far. Basically, I开发者_开发技巧\'m building an ASP.NET MVC 3 site that I would like to host from a central database and server.

Hoping there's been a "best practices" way to accomplish this so far.

Basically, I开发者_开发技巧'm building an ASP.NET MVC 3 site that I would like to host from a central database and server.

I'd like for [domain1].com and [domain2].com to point back to this one server. Ideally, I'd like this server to see a request from domain 1, and serve content relevant to domain 1 (which is essentially a category of topical information -- the rest of the structure would be the same). I'd like folks not to get redirected away from that domain if possible.

I'm thinking I should map each domain to a specific static IP, have all connections through those IPs connect to the central site, and return relevant data that way.

What experiences have folks had doing this with the .NET stack, and are there any "best practices" to consider in this case?

This might not be as clear as it could be; I'll aim to revise as I get questions.

Thanks in advance for your help!

-- Sean


The term you are looking for is "host header" to distinguish sites. See following article that describes behavior of IIS - http://www.it-notebook.org/iis/article/understanding_host_headers.htm.

One of the ways is to configure IIS to serve 2 different sites based on host name by configuring binding for each site appropriately (see http://technet.microsoft.com/en-us/library/cc753195(WS.10).aspx ) .

You can also serve all domains from the same site. In this case you'll need to check HOST of incoming request and change routing appropriately. You'll likely need to write you own routing as I don't think MVC support routing by host out of the box.

0

精彩评论

暂无评论...
验证码 换一张
取 消