Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This may be better suited for Server Fault, so someone can migrate it if need be.

For the purposes of testing, I want to redirect a domain name I own to my localhost. How do I do this? Can I simply set the redirect to 127.0.0.1? Also, I am using windows. Any help is appreciated.

share|improve this question
add comment

3 Answers

In your Windows HOSTS file you can set a mapping from your domain to your localhost (127.0.0.1):

127.0.0.1   example.com

Located in C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS

Any requests for example.com will then go to your localhost - this is suitable for testing just on your local machine.


If you want to be able to test this from any machine on your LAN (including phones, tablets, etc.) then you can set an A record in the DNS Zone for that domain (perhaps for a localtest. subdomain) that points to the internal IP address of your server. eg. 192.168.1.20.

share|improve this answer
    
Perfect solution if you want it to work only locally. –  gronostaj Mar 1 '13 at 23:59
    
This was my first thought, too, so I tried adding an entry for microsoft.com. Didn't work. I still got the genuine Microsoft site. Possibly I should have rebooted or done something else to clear my caches. –  Nicole Hamilton Mar 2 '13 at 0:03
    
@NicoleHamilton: Your machine/browser (some more than others) will cache the resolved DNS, so you might not see the change immediately. You can forcefully clear the DNS cache with ipconfig /flushdns from the command line. ... You also need a web server running on the localhost that is listening for requests to example.com. –  w3d Mar 2 '13 at 0:07
    
Sorry, you must have misunderstood what I meant. I want all traffic that tries to access mydomain.com to be redirected to my local server –  EpicPineapple Mar 2 '13 at 0:11
    
@TehEpicPineapple: A local (web)server on your LAN? Yes, the HOSTS file can do this. If the server is not the localhost, then substitute the IP address for whatever is the local IP address of your server. Or are you wanting this to be accessible from outside of your LAN? In which case you'll need to setup A records in the DNS, as in MarkusDBX's answer. –  w3d Mar 2 '13 at 0:16
show 1 more comment

First you need your external IP address, if you want anyone else to reach your domain.

Second you need a DNS server that holds your domain record, and uses an A Host record to point to your external IP.

Then you need to setup your domain to use that DNS server. Probably in the control panel, of the company you used to register the domain.

share|improve this answer
    
If you only have on public IP address and your internal network is NAT you may also need to setup the port forwarding to your server. –  Eric G Mar 2 '13 at 0:19
add comment

The answer will differ depending on whether your local network is on a dedicated IP or not.

If your external IP is dedicated, set an A Record to that IP. You should be able to do this through your domain provider's control panel.

If your external IP is dynamic, like on most home networks, you'll need to use a Dyamic DNS service to always update your domain to point to your local IP, even after it changes. Dyn has been doing this for as long as I can remember, but plenty of organisations offer this service.

After that, it's down to your local network config, which hasn't been mentioned in the question. Presuming you're behind some sort of router, you'll need to tell that direct traffic to your local server's local IP for whatever ports you're using.

share|improve this answer
    
It doesn't seem like he wants to redirect everyone to his computer. Rather, he only wants the redirection to happen on his private network. –  cpast Mar 2 '13 at 3:02
    
He said above, "Sorry, you must have misunderstood what I meant. I want all traffic that tries to access mydomain.com to be redirected to my local server" so I take that to mean external traffic as well... –  Andrew Lott Mar 3 '13 at 15:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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