Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

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

This question is unlikely to 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. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
OP requested it be closed. –  Chopper3 Jul 9 '11 at 9:15

2 Answers 2

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?

share|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

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?
share|improve this answer

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