Our application (http://www.example.org/) allows contributor users to create HTML content and upload assets (using TinyMCE editor and an asset uploader component), which are then stored in our database (for the HTML content) and an assets server (http://static.example.org/). The HTML is then rendered to reader users by inserting it "as-is" dynamically into a page.
We would like to maintain our pre-production environment (http://www-pp.example.org/) as close to the production as possible, by periodically importing the production database and assets (http://static-pp.example.org/).
The problem with this setup is that the asset URLs contained in the replicated database point to our production assets server instead of the pre-production.
Is there a way to solve this problem other than running a script to update all asset URLs when restoring the production backup? For example, we would like to be able to store relative URLs in our database, and dynamically set a base URL for all of the assets (we can't use the <base>
HTML tag because this base URL logic does not apply to all relative URLs in the page displayed to the users).