tags:

views:

43

answers:

5

I have a stylesheet that has stuff inside like background: url(/images/foo.gif) that I copied from live to test. It works fine on live, but not on test. This is because test does not have the /images contents. Other than doing a find/replace from "url(/" to "url(http://live/" or copying /images to test, is there a good way to fix this? Note that when test pages that are on test go live, they will be on live.

A: 

You could put <base href="live"> in the <head> of test. This replaces the current domain with the given href in all urls that begin with /.

Rusky
This doesn't pass through to stylesheets (except possibly in Netscape 4.x)
David Dorward
That's the strategy I used with the html itself.
Brian
A: 

No. You need to have a copy of your images folder on each server.

driis
A: 

Once the image folder is not relative to the location of the stylesheet, you will need to replace the /images of the test with the absolute location of http://live/images.

Shawn Mclean
A: 

So in summary, you need to change the CSS of test to point to the live images, but you need to do it without modifying the CSS? I guess if it was easy, you wouldn't have asked.

One suggestion might be to create an alternate test-only stylesheet that overrides the relevant classes and points to the production images properly, but only gets loaded on test. How you would accomplish this would depend on your code. If you maintain separate live and test config files, you can probably work it in to the configuration (ie. if test.css exists, include it).

zombat
A: 

You could use software such as Charles Proxy to remap /images/ to http://live/images/ — all testers would need a copy installed.

You could also install a proxy, such as mod_proxy, on the webserver.

David Dorward
Actually, this is somewhat akin to how the real setup is going to work, though the reasoning for doing it this way is to solve a different problem than the one I am asking about.
Brian