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   

Add To Your Reader

My Links

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<May 2008>
SMTWTFS
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Comment Stats

DayTotal% of Total
Sunday 1866.8%
Monday 37913.9%
Tuesday 45316.7%
Wednesday 50418.5%
Thursday 53519.7%
Friday 49418.2%
Saturday 1666.1%
Total 2717100.0%

Hour1Total% of Total
12:00 AM 652.4%
1:00 AM 682.5%
2:00 AM 622.3%
3:00 AM 742.7%
4:00 AM 572.1%
5:00 AM 1033.8%
6:00 AM 1084.0%
7:00 AM 1585.8%
8:00 AM 1716.3%
9:00 AM 1475.4%
10:00 AM 1716.3%
11:00 AM 1816.7%
12:00 PM 1886.9%
1:00 PM 1696.2%
2:00 PM 1605.9%
3:00 PM 1324.9%
4:00 PM 1073.9%
5:00 PM 923.4%
6:00 PM 913.3%
7:00 PM 963.5%
8:00 PM 833.1%
9:00 PM 782.9%
10:00 PM 792.9%
11:00 PM 772.8%
Total 2717100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.54144
Monday 5.22339
Tuesday 4.28419
Wednesday 7.67637
Thursday 6.90607
Friday 5.48411
Saturday 5.33160
Total 5.842717

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.35107
9:00 AM 6.32278
10:00 AM 6.47246
11:00 AM 4.41181
12:00 PM 6.88330
1:00 PM 3.00111
2:00 PM 5.41222
3:00 PM 8.64285
4:00 PM 4.0589
5:00 PM 5.92154
6:00 PM 4.52113
7:00 PM 9.67174
8:00 PM 9.80147
9:00 PM 5.05111
10:00 PM 5.4265
11:00 PM 4.5732
Total 5.842717

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


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles