Actions
Share

When hosting multiple domains and/or 3rd level domains in my account, how do I direct the browser to the proper web site?

There are basically three ways to do this on your VPS account:

1. Virtual Director
With our Virtual Director ISAPI-based filter, you can map a domain name to a physical path in your directory, avoiding the need to redirect, and avoiding the subfolder path in the URL. Please see this page for more info.  If you would like the Virtual Director installed in your account, please let us know your AccountID (V0xxxxxx), and email us at support@MaximumASP.com.

2. ASP.NET HttpModule
If you are using .NET and familiar with writing .NET code, then you can create an HttpModule to redirect based on domain name.  Check out the following articles for tips and sample code:

Rewrite.NET -- A URL Rewriting Engine for .NET
http://www.15seconds.com/issue/030522.htm


Domain Forwarding with IHttpHandler
http://www.codeproject.com/aspnet/domainforward.asp

3. ASP Based Redirect
If you are using ASP and familiar with writing ASP code, you can programmatically forward the user to the proper subfolder. The following sample script will show you ways of directing the browser, based on end user input.

'Sample script illustrating how to direct the browser to the proper page
Dim Host
dim ServerDir
dim PageURL
Dim contentsWidth, newsWidth
host = lcase (request.servervariables("SERVER_NAME"))
serverDir = ""
SELECT CASE host


'this example directs to a folder
CASE "www.peanutbutter.com"
serverdir="/pb"
CASE "peanutbutter.com"
serverdir="/pb"

'this example directs to a page
CASE "www.jelly.com"
serverdir="jelly.asp"
CASE "jelly.com"
serverdir="jelly.asp"

'this example uses a third level domain (CNAME)
'to direct to the user folder
CASE "www.billybob.countryclub.com"
serverdir="/users/billybob"
CASE "billybob.countryclub.com"
serverdir="/users/billybob"

'this example catches any other requests, (ip address, other CNAMES, etc...)
CASE else
serverdir="/anyfolder"

end SELECT
response.redirect serverDir

Article ID: 29, Created On: 1/26/2001, Modified: 8/23/2005

Feedback (0)