2 or More Domain Names Linked to the Same Folder

February 1, 2009 | By

Most if not all web hosting services allow users to link two or more domain names to the same account to save them the cost of a new account for each domain name. With such accounts, opening any of the registered domain names calls the same default page as the other. The solution is to write a Response.Redirect() call in the default page (usually Default.aspx) to redirect the user depending on the domain name entered.

The server variable SERVER_NAME contains the domain name part of the URL, so if the user entered ‘http://example.com/folder1/default.aspx’ its content will be ‘example.com’, and if the user entered ‘http://www.example.com/folder1/default.aspx’ its content will be ‘www.example.com’. To check for both versions always use the String object’s Contains() method, instead of checking for equality.

Filed in: ASP.NET, Mono 2.0 | Tags:

Comments (2)

  1. daian
  2. Thank you Daian very much.