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.

I have a linux test machine which I would like to run a copy of a production webserver. This is a legacy application which does not use a property file for its server name. Throughout the application, the server name is hardcoded (example: open connection to myServer.myCompany.com).

Is there any linux trick which I can use to redirect all requests for a certain host back to localhost? I know in Windows that I can add an entry to the hosts file and have it redirect back to localhost. How do I do this in linux?

share|improve this question

2 Answers 2

Add the following line to /etc/hosts:

127.0.0.1 myserver.mycompany.com

share|improve this answer
    
Will that work if myserver.mycompany.com is sometimes referenced by http and other times with https? Even with different ports (besides 80)? –  somebody Jun 1 '10 at 20:20
    
Yes, it will. You're only specifying what IP myserver.mycompany.com resolves to. It doesn't matter what service you're connecting to on that IP. /etc/hosts is at OSI layer 3, the services are a layer 4 construct. –  baumgart Jun 1 '10 at 21:54

It looks like modifying the etc/hosts file should fix this......

share|improve this answer
    
This is really a comment, not an answer to the question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. –  Matthew Aug 11 '12 at 1:11
    
@Matthew: He's self-answering I think, or he meant to improve his question. –  Tom Wijsman Aug 13 '12 at 14:53

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.