Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
show 8 more comments

1 Answer

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 127.0.0.1
  • 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
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.