Detecting the requested domain name??

  • Thread starter Thread starter andrew sargent
  • Start date Start date
A

andrew sargent

Hi,
I have two domain names pointing to the same webspace, but i want them to be
directed to seperate directories on the server:
www.web1.com -> dir "Web1"
www.web2.com -> dir"Web2"

The company hosting my website dont allow more than one domain to pointto
seperate directories (to prevent reselling), but suggested that some code
could be written to direct the browser to the appropriate directory
depending on which url was used.

Any ideas on how I can determine which URL the user wants so that i can then
redirect them to the appropriate homepage??

Thanks

Andrew
 
I have two domain names pointing to the same webspace, but i want them
to be directed to seperate directories on the server:
www.web1.com -> dir "Web1"
www.web2.com -> dir"Web2"

Something like this in your global.asax Session_OnStart should do the
trick.

Dim sname as string = Request.ServerVariables("SERVER_NAME")
sname = ucase(sname)
if InStr(sname,"DOMAIN1") <> 0 then
response.redirect "subdirectory to go to"
elseif InStr(sname,"DOMAIN2") <> 0 then
response.redirect "2nd subdirectory to go to"
elseif.......
end if
 
Thanks for your help, but that doesn't seem to do the trick.
looks like i will just have to get a seperate hosting plan for the second
site.

Andrew
 
Thanks for your help, but that doesn't seem to do the trick.
looks like i will just have to get a seperate hosting plan for the second
site.

I think you need to do this client-side in your default.aspx file...

<script language="Javascript">
var URL;
URL = window.location;

if (URL == "http://www.redproductioncompany.co.uk/" || URL ==
"http://www.redproductioncompany.co.uk")
{
window.location.href=("http://www.redproductioncompany.com/home1.asp");
}
else if (URL == http://www.redproductioncompany.com/" || URL ==
"http://www.redproductioncompany.com")
{
window.location.href=("http://www.redproductioncompany.com/home1.asp");
}

</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top