Scott on Writing

Musings on technical writing...

Hosting Multiple Sites from One Web Application

Back in May of this year I wrote a blog entry on my first year of hosting ScottOnWriting.NET and other assorted sites with WebHost4Life.  One of the pros of WebHost4Life that I mentioned in the review is that you could host multiple Web sites on one account, using one of two options:

  1. Paying $15/year to have a domain name map to a specific directory.
  2. Paying nothing, and having the default.aspx page in your site check the URL and redirect the request to the appropriate subdirectory.

The first approach is definitely more professional, as a request to www.somesite.com will remain as www.somesite.com in the user's browser, and not require an extra request to the Web server.  With the second approach, however, when a user visits www.somesite.com, they'll be redirected to some other subdirectory on the site, like www.somesite.com/ss.  I use this approach here on my blog (note that if you visit www.ScottOnWriting.NET you get auto-redirected to www.ScottOnWriting.NET/sowBlog).

Anywho, a poster named Chris had the following question:

 Excuse me for being completely new to ASP.NET, but in I was wondering if you could point me to a tutorial on the "hosting multiple sites using default.aspx" method? I'd like to try this as I can't justify $15 per domain. Thanks!

Chris, here is the code I use in the root Web directory's default.aspx page to redirect the user to the appropriate subdirectory based on their URL (this code would go in the Page_Load event handler):

If Request.Url.Host.ToUpper().IndexOf("SCOTTONWRITING.NET") >= 0 then
     Response.Redirect("/sowBlog/")
     Response.End()
ElseIf Request.Url.Host.ToUpper().IndexOf("SKMMENU.COM") >= 0 then
     Response.Redirect("/menu/")
     Response.End()
ElseIf Request.Url.Host.ToUpper().IndexOf("NBAWEBLOG.COM") >= 0 then
     Response.Redirect("/nba/")
     Response.End()
End If

As you can see, there are three URLs that will redirect the visitor to a specific subdirectory: ScottOnWriting.NET, skmMenu.com, and NBAWebLog.com.  This approach is used to host these hobby/personal sites all on one WebHost4Life account without having to shell out the extra $15/year for the Web server-level mapping of domain name to subdirectory.

Hope this helps, Chris!

posted on Friday, August 20, 2004 10:50 AM

Feedback

# re: Hosting Multiple Sites from One Web Application 8/20/2004 5:11 PM AjarnMark

Hey, nice trick, Scott! I, too am using Webhost4Life for a few personal and business domains that I manage. Frankly, I was pretty excited that I could add domains for *only* $15 per year instead of the outrageous monthly fees I had experienced before.

One follow-up question, are you doing some sort of domain forwarding on the others to get them to end up at your master site where the default.aspx is? Or what am I missing in the setup here?

# re: Hosting Multiple Sites from One Web Application 8/20/2004 6:10 PM Chris

Thanks Scott, that was exactly what I was looking for.

To AjarnMark: $15 is a bit steep for me, being a starving college student and all. =P

Thanks again,
Chris

# re: Hosting Multiple Sites from One Web Application 8/20/2004 10:06 PM Scott Mitchell

AjarnMark, no domain forwarding on the other domains. All point to the same nameserver, I just check the URL and re-route accordingly.

# re: Hosting Multiple Sites from One Web Application 8/23/2004 12:05 AM AjarnMark

Chris, sure, I understand. It's all a matter of perspective. Coming from an enviro where it was more like $15/month per domain, the $15/year sounded like a bargain! But free is even better.

Scott, OK, I get it now. I went back to the Webhost4life control panel and see that you can add a domain to your root folder (apparently for free). I had overlooked that configuration setting. Now I'm going to have to rethink my strategy, especially since I'm looking at adding one more. Thanks again for the info!

# re: Hosting Multiple Sites from One Web Application 8/24/2004 11:36 AM Josh

I'm using approach 1 because I agree that it's definitely a little more professional. However, the second approach is a great tip for those looking to get hosted on the cheap!

# re: Hosting Multiple Sites from One Web Application 9/20/2004 3:27 AM Julian Roberts

I tried this kind if methodology once, works quite well. But, the SEO guys working on the project were up in arms. Saying that one shouldn't do an auto-redirect from domain root. They claimed that a domain could be blacklisted for 5 years by search engines. Not sure how much truth there is in this.

# re: Hosting Multiple Sites from One Web Application 10/4/2004 9:50 PM Suresh Bhardwaj

hi

could u please help me which method is better
and what are there positive and negetive points.

--if i have a ecommerce web application and upload to my client server space, but my client have 4 or 5 sub company which are diffrenet from each other e.g. xyz.com,xxx.com,yyy.com etc. and want to use with diffrent domain name

so i have a two solutions for this problem

1:- is if i make 4 diffrent virtual folder for accessing diffrent sub company domain name.

2: if i make virtual folder only one and accessing with 4 diffrent url than what security i put in that case and how i implement this?

regards suresh bhardwah

sbhardwaj@quark.co.in


Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<March 2010>
SMTWTFS
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Comment Stats

DayTotal% of Total
Sunday 2056.8%
Monday 42514.1%
Tuesday 51917.2%
Wednesday 55518.4%
Thursday 58019.2%
Friday 54718.1%
Saturday 1886.2%
Total 3019100.0%

Hour1Total% of Total
12:00 AM 782.6%
1:00 AM 812.7%
2:00 AM 682.3%
3:00 AM 822.7%
4:00 AM 692.3%
5:00 AM 1264.2%
6:00 AM 1183.9%
7:00 AM 1816.0%
8:00 AM 1926.4%
9:00 AM 1585.2%
10:00 AM 1886.2%
11:00 AM 1936.4%
12:00 PM 2016.7%
1:00 PM 1846.1%
2:00 PM 1695.6%
3:00 PM 1354.5%
4:00 PM 1153.8%
5:00 PM 1073.5%
6:00 PM 1013.3%
7:00 PM 1073.5%
8:00 PM 923.0%
9:00 PM 882.9%
10:00 PM 913.0%
11:00 PM 953.1%
Total 3019100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 4.97159
Monday 4.80384
Tuesday 4.04477
Wednesday 7.39680
Thursday 6.26676
Friday 5.07466
Saturday 4.78177
Total 5.403019

Hour1 Entry MadeAvg.Total
12:00 AM 5.2937
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 3.8550
8:00 AM 3.72134
9:00 AM 6.06297
10:00 AM 5.63276
11:00 AM 4.22194
12:00 PM 6.16351
1:00 PM 3.09133
2:00 PM 4.89230
3:00 PM 7.64321
4:00 PM 4.00108
5:00 PM 6.07170
6:00 PM 4.64116
7:00 PM 8.95188
8:00 PM 8.63164
9:00 PM 5.00115
10:00 PM 6.31101
11:00 PM 4.5732
Total 5.403019

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles