Jump to content

Create "subdomain" with HOSTs file


ShadowMage

Recommended Posts

Hey guys, just wondering something. I currently have an intranet set up and I'm using HOSTs files to redirect to it. When I type portal.domain.com I get redirected to the webroot on the webserver, which is what I expect. What I'd like to know is if it is possible to have an entry in the HOSTs file that will redirect subdomain.domain.com to webroot/subdomain on the webserver. Something like this:

1.1.1.1			  portal.domain.com1.1.1.1/subdomain	subdomain.domain.com

The above is what I tried but that doesn't seem to work. Am I trying to do something that can't be done?

Link to comment
Share on other sites

You can't do that with HOSTS, that file just lists host names and what they map to. "1.1.1.1/subdomain" is not a host, it's a path.
That's what I was afraid of... :) Is there another way to do that? (besides DNS [EDIT: Actually, I'm not certain DNS can do that either, can it?])
Link to comment
Share on other sites

You could set up the subdomain as a site and then redirect it to another URL...
I'm not quite sure I understand...How would I do that?The server is IIS 7 (Or is it 7.5? Whatever comes with Win 7 Pro) with PHP 5.3 and MySQL (can't remember the version) if that helps.
Link to comment
Share on other sites

You can go to the properties for any web site in IIS and redirect all requests to another URL, I was thinking of doing it that way. You can also just point it to the same directory so that the URL doesn't change, but they're getting content from the directory.

Link to comment
Share on other sites

You can go to the properties for any web site in IIS and redirect all requests to another URL, I was thinking of doing it that way. You can also just point it to the same directory so that the URL doesn't change, but they're getting content from the directory.
Alright thanks. I'll have to do a little digging around, see what I can figure out. Thanks for the pointers, jsg.
Link to comment
Share on other sites

You can go to the properties for any web site in IIS and redirect all requests to another URL, I was thinking of doing it that way. You can also just point it to the same directory so that the URL doesn't change, but they're getting content from the directory.
It works!! Thank you, jsg!I just went into IIS manager and created two sites, one for portal.domain.com and one for games.domain.com, and pointed them both to the same IP address but using different directories. I also had to create entries in the HOSTs file for portal and games pointing to the same IP that the websites pointed to since for some reason it wouldn't work if those entries weren't in HOSTs (though I would think it would, but hey, it works now)Thanks once again, jsg.
Link to comment
Share on other sites

I also had to create entries in the HOSTs file for portal and games pointing to the same IP that the websites pointed to since for some reason it wouldn't work if those entries weren't in HOSTs (though I would think it would, but hey, it works now)
That sounds like a DNS issue, you need to add entries for those subdomains into the domain's DNS records to get it to work on any machine where you don't want to change the host file.
Link to comment
Share on other sites

  • 1 month later...
That sounds like a DNS issue, you need to add entries for those subdomains into the domain's DNS records to get it to work on any machine where you don't want to change the host file.
Heh, I must've missed this. :)There's no DNS. It's just a single windows 7 workstation with PHP, MySQL, and IIS installed on it. It's on a small home network with one other computer.
Link to comment
Share on other sites

Your router may be able to act as a DNS server.
Oh yeah. Never thought of that. Thanks, Synook. I'll have to look into that to see if I can get it configured. I think I vaguely remember seeing some kind of options for doing something like that when I set it up initially. Now I just have to remember the password.......:)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...