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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to indentify the subdomain in ASP ???

Status
Not open for further replies.

asuknow

Programmer
Sep 28, 2001
26
US
Supppose I have a subdomain called "sub.mydomain.com"
pointing to a directory "/sub" under .

I also have mysub.asp under /sub.
if I use server_name in serverviriables in mysub.asp
to detect the server name, will I get a value of
" or "sub.mydomain.com"???

If I cannot indentify subdomain by this method, could
anyone suggest an alternative way?

Thanks a lot!
 
It's really hard to say. You're just going to have to try a few different ServerVariables to come up with a solution. Here are a few suggestions.


Request.ServerVariables("APPL_MD_PATH")
Request.ServerVariables("APPL_PHYSICAL_PATH")
Request.ServerVariables("INSTANCE_META_PATH")
Request.ServerVariables("PATH_INFO")
Request.ServerVariables("PATH_TRANSLATED")
Request.ServerVariables("URL")
Request.ServerVariables("HTTP_HOST")
Request.ServerVariables("SERVER_NAME")



You can also use the window.location.href property in JavaScript which will return the entire address line in the browser window. You'll have to do some stripping to get to the sub domain part of the address, but it's definitely not impossible.

Let me know if you need more details.. :)

ToddWW
 
Thank you for your reply.
I have a problem of doing this.
I currently do NOT have a subdomain and I am going to apply for a subdomain
soon.
Before I set up a subdomain, I need to know the way to get the subdomain name
in the server side script.
But since I do NOT have a subdomain now, I cannot test whether subdomain name
will be shown in the value of any of the server variables you suggested.

Hope I can get some idea of identifying subdomain by ASP before I apply for a
subdomain.

Thanks!
 
One more question:
What's the difference between server_name and http_host?
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top