Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hosting multiple domains using server variables 2

Status
Not open for further replies.

towntopic

Technical User
May 15, 2003
103
US
hi, this is my first experience with ASP so forgive me for stupid questions. here's my problem. XP IIS 5.X does not support multiple domains and i need to be able to host a 2nd domain for a while. so, on the domain side of things, i've created A records on both domains that point to the same IP address. Then I found out that you can use an ASP page that uses server variables to determine with domain the client request is coming from and by that you can then redirect to the appropriate web page. here's the code i used...i'm concerned with the paintergoode redirecting to "/paintergoode/index.htm"

is there anything else i should be worried about?

<%
domainname = request.servervariables("HTTP_HOST")
SELECT CASE domainname
CASE " response.redirect "/paintergoode/index.htm"
CASE "paintergoode.com" response.redirect "/paintergoode/index.htm"
CASE "towntopic.net" response.redirect "home.htm"
CASE " response.redirect "home.htm"
CASE ELSE response.redirect "home.htm"
END SELECT
%>

also, is this the best way to accomplish what I am needing to do?

thanks for any insight you might be able to provide.
 
I don't think this will work. One potential problem is that you'll always get the true domain name -- I'm not sure that Servervariables won't auto-translate.

What will certainly happen, though, is if the "fake" domain has any relative links, they'll automatically be translated into the "true" domain.

Conceptually your code makes sense, with the above caveats.
 
I've been agonizing over a similar situation. I develop several webs on my XP Pro then publish them to various websites. So, in a sense, I host several websites on my development machine. Trying to refer to pages and directories is driving me nuts. If I try to use VIRTUAL references, they will either work on my machine and not on the hosted website or visa versa. I've been working on an idea using a function to determine the "root" of the web in question, but I'm not quite there. The method I'm using right now is to place a unique file in the web's root (I'm using a text file I call Locator.txt) and then parse out the actual location.

Code:
' Requires the file Locator.txt to be in the web root directory
Function WebRoot()
on error resume next
     Dim tmpFile
     tmpFile = "locator.txt"
     Set fs=Server.CreateObject("Scripting.FileSystemObject")
     do while not (fs.FileExists(WebRoot))
          tmpFile = "../" & tmpFile
          WebRoot = server.mappath(tmpFile)
          if len(tmpFile) > 30 then exit do
     loop
     if not (fs.FileExists(WebRoot)) then
          WebRoot = server.mappath("/")
     else
	  WebRoot = left(WebRoot, len(WebRoot)-12)
     end if
     set fs=nothing
End Function

I keep adding "../" to the start of tmpFile to back down the path from the current page location until it either locates the file or exceeds a predetermined string length. I know, not very pretty.

I am very open to suggestions and I suspect help for me will also help towntopic.
 
actually, everything seems to be working exactly how i want. try out the two url's.


both are hosted on a XP pro box. towntopic.net is the "default web site" and then paintergoode is in the following location

C:\Inetpub\
I've set the default document in IIS for the default website to index.asp (the above code) and everything seems to be working really well. so if you've looking for a solution, try what i did above. if you want my index.asp file so you can see if, let me know @ john @ towntopic.net
 
Right, but I was referring to problems with links inside paintergoode (of which there are none available from the home page). That's where I'm concerned your problem will be.
 
try it now...

seems to work just fine. first timers luck i guess :)
 
Page references developed with server.mappath() and virtual references that take you back to the root directory ("/index.htm") won't work either.
 
thanks for the replies and insight on potential future issues. right now most everything will be developed within HTML and they'll have to live with the extra folder after the domain.

thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top