On my desktop I use /etc/hosts file like as below for developing purpose

127.0.0.1   a.example.com
127.0.0.1   www.a.example.com
127.0.0.1   adsense.a.example.com
127.0.0.1   foto.a.example.com

They all work except www.a.example.com it doesn't forward to localhost. Could you explain why? and any workaround?

I use Ubuntu 10.10. Thanks

link|improve this question

67% accept rate
OP requested it be closed. – Chopper3 Jul 9 '11 at 9:15
feedback

closed as too localized by Chopper3 Jul 9 '11 at 9:15

This question is unlikely to ever help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. See the FAQ for guidance on how to improve it.

2 Answers

up vote 0 down vote accepted

What do you mean with "They work"? Where? In a browser? On the console?

What is the output of

host www.a.example.com

or

dig www.a.example.com

on the console?

link|improve this answer
when I ping it doesnt route to 127.0.0.1 – Gok Demir Feb 22 '11 at 15:29
Where to then? Which IP address? Or what error do you get? – rems Feb 22 '11 at 15:37
Are you sure you don't have a syntax error in /etc/hosts? ping should work! – rems Feb 22 '11 at 15:38
I rewrote and it worked. Although I havent seen any difference it worked. probably I wrote wrong. – Gok Demir Feb 22 '11 at 15:44
feedback

Some theories:

  1. The www.a.example.com record is seperated by tabs as opposes to spaces for the rest, or visa-versa. In theory, the host file should accept either tabs or spaces, but ubuntu might be picky.
  2. Something else in your host file is taking precedence over www.a.example.com. Is there an entry for *.a.example.com
  3. Does www.a.example.com contain any unicode characters? If you display it with cat, less or more on a terminal doe it look funny?
link|improve this answer
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.