»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books
»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects
»Competition
Community
Winners
Prizes
Write For Us
Members
»Other Resources
Links
Dotnet Resources
|
Hosting multiple websites on one domainHave you ever wondered how you could host multiple websites on one domain hosting service.
Well it is simple with this asp.net script i achieve just that. This is very usefull for people like us who dont want to invest a lot of money for domain hosting.
///// add this in the asp.net page. load even as shown below
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
string url = Request.Url.ToString().ToLower();
string domain;
// get the domain name
if ( url.StartsWith( "http://" ) )
url = url.Substring( 7 );
int x = url.IndexOf( '/' );
if ( x > 0 )
domain = url.Substring( 0, x );
else domain = url;
// redirect based on domain
switch( domain )
{
case "www.domain1.com":
case "domain2.com":
Response.Redirect( "home.aspx", true );
return;
case "www.domain2.com":
case "domain2.com":
Response.Redirect( "index.html", true );
return;
}
Server.Transfer("index.aspx");
}
}
|
|