21

I know how to resolve a hostname to an IP address using my hosts file eg

1.2.3.4 example.com 

but is it possible to resolve a hostname to another

example.com example1.com 

with a hosts file? Reason being, Im testing a new site, hosting uses Virtual hosts, so there are multiple domains on the IP address. ServerAlias in Apache is not an option either.

Any help appreciated!

Thanks Stephen

stephen mc
  • 751
  • 2
  • 12
  • 22

2 Answers2

11

No.

You can add multiple hostnames to the hostfile, for example: 1.2.3.4 hostname1 hostname2

But every time you look up a name or address, youll just get the whole line back. Or was that what you wanted?

Sirch
  • 407
  • 3
  • 17
5

You can't resolve one domain to another, but you can have multiple hostnames for one IP like this:

1.2.3.4 example.com
1.2.3.4 example1.com
1.2.3.4 example.net
1.2.3.4 example.net
Sandman4
  • 2,673
  • 2
  • 22
  • 18