Allow one host name to another using the hosts file

I know how to resolve the hostname for an IP address using my hosts file, for example

1.2.3.4 example.com 

but is it possible to resolve the hostname to another

 example.com example1.com 

with hosts file? The reason is that I am testing a new site, the hosting uses virtual hosts, so there are several domains on the IP address. ServerAlias ​​in Apache is also not an option.

Any help appreciated!

Thanks Steven

+8
dns hosts
source share
2 answers

Not.

You can add multiple hosts to the host file, for example: 1.2.3.4 hostname1 hostname2

But each time you look at a name or address, you simply return the entire string. Or was that what you wanted?

+6
source share

You cannot resolve one domain to another, but you can have multiple host names for the same IP address, for example:

 1.2.3.4 example.com 1.2.3.4 example1.com 1.2.3.4 example.net 1.2.3.4 example.net 
+2
source share

All Articles