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
.
views:
43answers:
5You 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 /.
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.
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).
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.