How to redirect a domain to another one on my machine only?

2

1

I want all requests from my machine to

example.com

be redirected to

example.com.edgesuite.net

I tried adding the following line to the hosts file both on Windows and Linux

example.com.edgesuite.net        example.com

but the nslookup still resolves to the old IP.

Jader Dias

Posted 2010-01-07T13:02:21.877

Reputation: 13 660

Answers

2

The hosts file expects an IP address for each hostname listed.

You may need to look up the IP address of example.com.edgesuite.net and use it in the hosts file.

First perform the DNS lookup:

C:\>nslookup example.com.edgesuite.net
Server:  google-public-dns-a.google.com
Address:  8.8.8.8

Non-authoritative answer:
Name:    a1081.b.akamai.net
Addresses:  24.143.196.115, 24.143.196.123
Aliases:  example.com.edgesuite.net

Then add a line line in your hosts file such as:

24.143.196.115 example.com

or

24.143.196.123 example.com

But keep in mind that if example.com.edgesuite.net ever changes its IP address, then you will have to make a corresponding change in your hosts file.

eleven81

Posted 2010-01-07T13:02:21.877

Reputation: 12 423

it worked for pings but my nslookup still resolves for the old IP – Jader Dias – 2010-01-07T13:27:38.813

1@Jader Dias: do an ipconfig /flushdns and give it another try. That'll flush your resolver cache, maybe you've got the old records still stuck in the cache. – squillman – 2010-01-07T13:30:52.007

I tried it too, but it didn't work. Maybe nslookup doesn't looks into the hosts file (try nslookup localhost). – Jader Dias – 2010-01-07T13:33:53.483

1

If you want nslookup to behave as described in the above comments, then consider running your own DNS server and pointing your client(s) to that DNS server, such as http://www.powerdns.com/ PowerDNS.

– eleven81 – 2010-01-07T13:39:28.170

0

I had the similar need for my local environment (localhost). I use Firefox browser and installed the addon called "Redirector". Very basic and easy configuration (it took me less than 5 minutes to get the first redirection working). Thanks to Einar Egilsson!

In case you are wondering about settings:

Description: Anything

Example URL: https://example.com/

Include pattern: https://example.com/*

Redirect to: http://example.com.edgesuite.net/$1

Pattern type:  Wildcard

Apply to: (checked all)

Paulius

Posted 2010-01-07T13:02:21.877

Reputation: 21