For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > September 2004 > Detecting the requested domain name??









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Detecting the requested domain name??
andrew sargent

2004-09-30, 11:37 am

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


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.770 / Virus Database: 517 - Release Date: 27/09/2004


Lucas Tam

2004-09-30, 11:37 am

"andrew sargent" <as@nospam.com> wrote in
news:V7V6d.168595$hZ3.41343@fe2.news.blueyonder.co.uk:

> 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


--
Lucas Tam (REMOVEnntp@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
[url]http://members.ebay.com/aboutme/spot18/[/url]
andrew sargent

2004-09-30, 4:08 pm

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
"Lucas Tam" <REMOVEnntp@rogers.com> wrote in message
news:Xns957472771EFF3nntprogerscom@140.99.99.130...
> "andrew sargent" <as@nospam.com> wrote in
> news:V7V6d.168595$hZ3.41343@fe2.news.blueyonder.co.uk:
>
>
> 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
>
>
> --
> Lucas Tam (REMOVEnntp@rogers.com)
> Please delete "REMOVE" from the e-mail address when replying.
> [url]http://members.ebay.com/aboutme/spot18/[/url]



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.770 / Virus Database: 517 - Release Date: 27/09/2004


Mark Rae

2004-09-30, 4:08 pm

"andrew sargent" <as@nospam.com> wrote in message
news:cRV6d.168640$hZ3.127835@fe2.news.blueyonder.co.uk...

> 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>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com