SirM
SirM

Reputation: 497

How can I get a website sub-directory to use sub-domain url?

I have an ASP.NET 4.0 website (mysite.com) and will be adding new functionality to the project at mysite.com/talk. The kicker is I need the /talk sub-directory to be accessed and utilized using talk.mysite.com as the url. How can I do this in .net or IIS 6.0?

Upvotes: 0

Views: 263

Answers (1)

McGarnagle
McGarnagle

Reputation: 102723

There are several options here.

  1. Add a URL rewrite rule -- match the incoming hostname talk.mysite.com and rewrite it to mysite.com/talk.
  2. Create a new website within IIS (pointing to the /talk directory) and modify its binding information. Set the "hostname" so that it will only accept traffic on talk.mysite.com.
  3. Perform a redirect at the ASP.Net application level. Add an Application_BeginRequest handler to global.asax, and redirect if Request.Url.Host is talk.mysite.com.

The best one depends on the details of your scenario. I think #1 is probably the easiest (most straightforward), but one of the others might be a better fit in some cases.

Upvotes: 1

Related Questions