Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolve one hostname to another, using hosts file

Tags:

dns

hosts

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

like image 886
stephen mc Avatar asked May 01 '12 15:05

stephen mc


2 Answers

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?

like image 96
Sirch Avatar answered Oct 18 '22 12:10

Sirch


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
like image 30
Sandman4 Avatar answered Oct 18 '22 12:10

Sandman4