Point a subdomain to a sub-directory?

L

Leon

How do I point a sub-domain to a sub-directory or sub-web of my site using
asp.net?

I know normally domains are setup to point to the root directory of the web
site. However, how can I detect which URL a person is browsing to on my site
with ("such as leon.mydomain.com"), and redirect them to the appropriate
place on within site ("such as mydomain.com/help/leon05"), and where do I
want to put this code in default page of the website or in the global.asax
file.

Thanks!
 
B

Brock Allen

You need to configure a new website in IIS and it can use the HTTP host header
to distinguish which website to access. Then in your second website configure
to map to any directory you want to.
 
L

Leon

something like this would work right?

<%
sname = 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"
end if
%>
 
B

Brock Allen

Yes, I suppose that would work. The downside is that you'd have to code this
for every page, I presume? And what happens when you want to support a 3rd,
4th or 5th domain? Again, there are always two ways to skin a cat. I'd suggest
seeking out the sharper knife, though ;)
 
B

Brock Allen

Oh, I had assumed you had proper DNS entries for your domain and subdomains.
So if it's parked, then a redirect to your specific URL would also work.
 
L

Leon

I do I do a doamin forward from where the domain is parked, but mask or is
it impossible? See example below..
Parked domain = www.mydomain .com
so I set-up a domain forward to www.maindomain .com, but I want the url to
keep showing mydomain.com.
 
B

Brock Allen

Ah, but that's a security problem. The redirect is going to be your best
bet. The other hack I've seen is to make your first domain have a page that
contains a frame that points to the second domain. This sort of works, I
guess :)
 
L

Leon

thanks so much for your time, but what do you mean by "The other hack I've
seen is to make your first domain have a page that contains a frame that
points to the second domain"?
 
B

Brock Allen

So for the domain whose name you want to keep in the address bar, make a
default.htm that does something like this, you'll have to get all the right
attributes but this should give you the idea:

<html>
<frameset>
<frame src="http://otherdomain.com" />
</frameset>
</html>
 

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

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top