Graeme McGilvray
asked on
identifying sub domains in webpage
Hey all, just wondering if there is a way to identify which subdomain is being used on the page, there fore displaying a specific image for it
eg.
sub1.domain.com.au > image of monkey
sub2.domain.com.au > image of tiger
the pages are identical, just need an if statement to identify the subdomain
Thanks in advance
eg.
sub1.domain.com.au > image of monkey
sub2.domain.com.au > image of tiger
the pages are identical, just need an if statement to identify the subdomain
Thanks in advance
To get the sub domain name server side you could use the following server variable:
url = Request.ServerVariables("S ERVER_NAME ")
then you can do an if statement on that variable and display the appropriate image
url = Request.ServerVariables("S
then you can do an if statement on that variable and display the appropriate image
ASKER
Big Monty, are you able to give an IF statement example?
Sure no problem, try the code below and let me know if you have any questions.
If you have multiple conditions you want to check, just add them in the IF statement.
url = Request.ServerVariables("SERVER_NAME")
If InStr( url, "sub1" ) > 0 then
Response.Write "<img src=' monkey.png' />
elseif InStr( url, "sub2" ) > 0 then
Response.Write "<img src=' tiger.png' />
end if
If you have multiple conditions you want to check, just add them in the IF statement.
ASKER
Thanks for the BigMonty, it sends back the whole domain, not the just the sub (which is what i would like)
ideas?
ideas?
it sends back the whole domain, not the just the sub (which is what i would like
not sure what you mean by this. the code just checks for any occurrence of the string "sub1" in the first if statement and for the string "sub2" in the 2nd if statement.
if you do a Response.Write URL, what do you get?
ASKER
Hi BigMonty. I get the full domain. Eg
Sub1.maindomain.com
I just would like sub1 as the outcome
Sub1.maindomain.com
I just would like sub1 as the outcome
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Looks a treat! thank you very much!
Open in new window