Load local file in place of remote file (HTTP) address in Windows

3

I am trying to achieve something that you might typically use a hosts file for, but that isn't suitable here.

I want a Windows PC to refer to a local file (I can serve it from a web server at localhost if needed) when it attempts to fetch a certain remote file via HTTP. However, I need other files from that particular remote web server to be fetched as usual.

Any help appreciated.

Edit:

The specific case is that I'm customising a web application which I don't own and can't run locally. It is a hosted web app, and custom css is added through a standard html text field, which is immediately applied to your production site. This of course limits my testing options.

So, I have been testing by applying a user-specified css file from my local machine. This works great in browsers that allow it.

I want to test old browsers that don't allow user-specified css, so I want to intercept all outbound requests to the remote css file and redirect them to a local css file (which I can refer to using file://, http://, whatever - I will do what I have to do. If the recommended method requires the local file to be served using http, I don't mind firing up a quick instance of Python's SimpleHTTPServer on a local port).

I can't redirect the entire hostname, because then the third-party site won't load at all. I just want to intercept requests to one particular URL and instead point at my local file.


I should also note that the remote web app does not allow the use of css import statements, because that is the obvious solution to this problem.

ev.

Posted 2010-05-12T23:49:51.770

Reputation: 185

Answers

2

Many HTTP proxy servers (such as Squid or Privoxy) are able to redirect requests.


Squid:


Privoxy:

{ +redirect{http://localhost/example.com.css} }
example.com/stylesheet\.css$

user1686

Posted 2010-05-12T23:49:51.770

Reputation: 283 655

Privoxy looks like an easy solution. Cheers. – ev. – 2010-05-14T00:38:56.167

It worked perfectly - took about 15 minutes to set up and I've never used privoxy before. Thanks again for the recommendation. – ev. – 2010-05-14T01:07:13.740

0

If by "web server" you mean "httpd" then mod_proxy's ProxyPass is what you're looking for.

Ignacio Vazquez-Abrams

Posted 2010-05-12T23:49:51.770

Reputation: 100 516

Hi, thanks for the response. I think this might be overly complicated for what I'm hoping to achieve (see new information provided above). However I will keep looking into it as a proxy solution may be necessary. – ev. – 2010-05-13T02:08:22.797