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

detect subdomain 3

Status
Not open for further replies.

Bignewbie

Programmer
Feb 22, 2001
351
0
0
PH
Hi guys,

is there any way to know if the user typed in a subdomain or not? its like this... when a user types in I show him/her the site, but if he types in images.mysite.com or he/she will be redirected to a menu page listing all the images by category. I want to do this using ASP, without setting anything on my IIS server. Is this possible?



hope to hear from you guys soon!


respectfully yours,


biggie




The Man of Tomorrow is forged by his battles today.
 
Not it's not posible from ASP.

How domain names works.

Example when browsing
type in browser then the browser starts to interogate first DNS(domain name server) server who is in your TCP-IP configuration for that domain. if the DNS server knws what domanin is ig gives back to the browser the real IP adress with some other data if DNS server doesnt knw it gives the request to it's DNS parent server and so on till the request it's solved. Usualy those domains are cached on most of the DNS servers.

Names are used mostly to hide the real IP adress which is hard to keep in mind.

So in your case you have to already register that domanin name and then you can make it's own asp page who could done your job

You can use this way tought
this wouldnt reqire to have a domain just a directory caled images in your web folder tree.

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Well... assuming the subdomains are valid (that is, there are DNS records in place) then
Code:
Request.ServerVariables("HTTP_HOST")
will give you the domain name, and
Code:
Mid(Request.ServerVariables("HTTP_HOST"), 1, InStr(Request.ServerVariables("HTTP_HOST"), ".") - 1)
should give you just the subdomain portion.
 
It depends on your ISP, too. We use discountasp.net and they allow unlimited subdomains as an upgrade. All subdomains are directed to our home page, and our default.asp script in the root directory of the web does this:

1. Picks out the subdomain the user entered using Request.ServerVariables("SERVER_NAME")

2. Uses that info to Response.Redirect to a specific script in a subdirectory, or

3. If not one of our recognized subdomains, redirects to our default page, index.html

Michael
 
I suggest you not use Response.Redirect for this. Many web spiders/crawlers (including Google) don't like redirects and often won't follow them, as they're commonly used to spam/fool search engines.

Instead I suggest you use Server.Transfer which transfers exectution to the page of your choice without sending a redirect message back to the browser (or spider/crawler).

Server.Transfer works like a charm for this purpose. It's also faster for the users of your site because it saves one round trip.
 
Should have used Left() in my example:
Code:
Left(Request.ServerVariables("HTTP_HOST"), InStr(Request.ServerVariables("HTTP_HOST"), ".") - 1)
Was pre-coffee.
 
Genimuse, thanks for the tip. For this particular site, we don't really want the spiders to follow. But I can see valuable uses for Server.Transfer.

Thanks!
mmcgon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top