stephen mc
stephen mc

Reputation: 771

Resolve one hostname to another, using hosts file

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

Upvotes: 22

Views: 21748

Answers (2)

Sandman4
Sandman4

Reputation: 2741

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

Upvotes: 5

Sirch
Sirch

Reputation: 417

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?

Upvotes: 11

Related Questions