Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking to reroute one particular URL to another, for example : http://website.com/page1.html to http://website.com/page2.html on a third party server only on my machine. But I still want it to reply as if it was page1.html. Is there a way to do that on a client UNIX ?

Alex PS : If any clarification is required, please tell me

share|improve this question
Are you looking to make this work such that if any program (wget, FireFox, etc) requests page1.html, the client machine automatically redirects the request to page2.html? – Justin Ethier Feb 18 '11 at 21:11
What you're looking for is called a web proxy. – Gilles Feb 18 '11 at 21:37
justin : yes, basically, on my machine, as I would in /etc/hosts/, say "any requests to that url get changed to this one" and then any program that I open thinks he's calling one page while actually the OS is requesting another one gilles: no, a proxy is external and makes me run all my connection through it. /etc/hosts/ is just the OS requesting different host but the program still thinks it's calling the original URL, plus it's as simple as adding a line in /etc/hosts. I need something built-into unix. – Alexandre Cassagne Feb 18 '11 at 21:47
Please clarify "on a third party server only on my machine". Do you mean that you want to fool your machine (and only your machine) into retrieving page2 when you ask for page1? I assume by "third party server" you mean it is one you do not have control over. EDIT: Never mind, your comment clarifies this. Didn't see it before posting. – Wodin Feb 18 '11 at 22:01
That's right, just fool my machine. – Alexandre Cassagne Feb 18 '11 at 22:05
up vote 1 down vote accepted

I posted another comment yesterday, but it is not here now!

Anyway, it seems that a proxy is probably the way to go, despite your reservations.

A proxy can run on your machine, and therefore needn't be external.

Changing /etc/hosts to fool your browser into connecting to site2 instead of site1 just affects name resolution and is easy. Getting your machine to fetch page2 instead of page1 is much harder.

You could probably do it this way if you do not want to configure the clients to use a proxy:

  • Add website.com to /etc/hosts pointing at
  • Set up a reverse proxy on your machine and configure it to point to the real website.com.
  • Configure the proxy to fetch page2 when page1 is requested.
share|improve this answer

Your Answer


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.