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?

link|improve this question
feedback

2 Answers

Add the following line to /etc/hosts:

127.0.0.1 myserver.mycompany.com

link|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
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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