Resolve one hostname to another, using hosts file

stephen mc picture stephen mc · May 1, 2012 · Viewed 18.1k times · Source

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

Answer

Sirch picture Sirch · May 1, 2012

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?