I tried to put the line to /etc/hosts:
IP math.com mathworld.com
where IP was supposed to be the IP of http://mathworld.wolfram.com/classroom/. I pinged the site, and I realised that I must direct traffic with some other tools:
ping mathworld.wolfram.com/
ping: cannot resolve mathworld.wolfram.com/: Unknown host
So the question arises:
How can I direct traffic to subdomains, similar to the above subdomain?
You seem to be confused about networking terminology.
http://mathworld.wolfram.com/classroom/ is a URL, not a domain name. It has no IP address.
mathworld.wolfram.comis a domain name and has an IP address.Also,
mathworld.wolfram.comis a subdomain ofwolfram.comwhich is a subdomain of thecomtop level domain.mathworld.wolfram.com is not a subdomain of mathworld.com
The
/etc/hostsis not powerful enough to map all subdomains of a domain to the same place. You will need to type them all out, or go into proper DNS server configuration (such asnamed.conf).