Detecting the requested domain name??

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
 
L

Lucas Tam

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
 
A

andrew sargent

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
 
M

Mark Rae

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

Members online

No members online now.

Forum statistics

Threads
473,796
Messages
2,569,645
Members
45,362
Latest member
OrderTrimKetoBoost

Latest Threads

Top