4

I have www.somesite.com blocked in my country. But I have another domain www.another.com that points to the same server and it's not blocked (Apache Virtual Host) and works fine.

I put an entry in hosts file of my computer as follows.

www.another.com          www.somesite.com

I still can't access www.somesite.com. Am I getting hosts file all wrong?

2 Answers 2

7

Yes, this is incorrect. Host files are designed to map a single host or a list of hosts to a single IP address. Instead, you've attempted to map a host to a host.

Assuming www.another.com and www.somesite.com do point to the same IP address, you could try the following.

1 - Ping the address you can resolve, which is www.another.com.

ping www.another.com

2 - Assuming the IP is 1.2.3.4, copy it into the host file, enter a space, then enter the domain you wish to map.

1.2.3.4   www.somesite.com

3 - On Windows, you may need to flush your browser cache. Open a command prompt and type:

ipconfig /flushdns

4 - You may still need to restart your browser. On Mac and Unix-based systems, the changes should be immediate.

Note that, depending on how the site is blocked, you may need to use other methods to get through. If it's blocked by your ISP and not DNS, then you'll likely need to look for an Anonymous proxy in order to fetch the content from a proxy in another country. You can find some proxies here, as well as on Google. Good luck!

Note: You can add more than one host to a single IP by spacing out the addresses:

1.2.3.4  my.domain.com  www.somewhere-else.com  anotheraddress.net
3
  • What if I say, this is single IP on which www.another.com, www.someother.com and few others are pointed by Apache Virtual Host. If I ping and get the IP address, this is not the webpage I want.
    – Umair A.
    Sep 29, 2012 at 9:20
  • This is the explicit need to map host to host. Is there a way in windows and mac to do that?
    – Umair A.
    Sep 29, 2012 at 9:22
  • No, you cannot control host to host, not without the IP. Plus, the target server, if using NameVirtualHost, will interpret the request by hostname anyway, so all you can do is tell your computer to point the domain to a specific IP address. Like I said, if this doesn't work, you'll likely just need to use a proxy.
    – jmort253
    Sep 29, 2012 at 9:39
1

Hostfiles point a domain name to an ip address (effectively acting like a A record), you can't use it to point a domain name to another name (like a C record). It simply dosen't work that way.

2
  • Got it. Is there a way to explicitly map host to host in windows and mac?
    – Umair A.
    Sep 29, 2012 at 9:29
  • The way you expect it to work? not really. If you map foo.net to bar.org, the request the server recieves is for bar.org. Not much use there.
    – Journeyman Geek
    Sep 29, 2012 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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