Loading images from another server with a relative path
I'm in a bit of a pickle! here's the issue...
I've got two servers;
'Server A' is the live server, accessed via www.example-a.com
'Server B' is the development server, accessible via www.example-b.com (IP restricted, but allows access to /img/ and as to not duplicate our CMS etc, we want to host all our image content here.)
The problem is, if we write a news post on via the CMS, and add images, it adds a relative path to say 'img/uploads/hello.jpg' which exists at: 'www.example-b.com/img/uploads/hello.jpg' but on the live website it's looking for the image in www.example-a.com/img/uploads/hello.jpg
Can i with possibly .htacecss re-directs(?) make any request that looks in img/uploads/ be redirected to look at www.example-b.com/uploads/ ?
I realise i can probably, with a bit of work alter all of my image paths in my site to use absolute links to look at example-b.com, but i'd rather not do this as it then means a bit headache later if we change how these sites are setup.
Just to add, another quick option i've considered would be using the meta base tag, but i think these also effect links which is a problem!
I've found a solution that seems to work...
Create a seperate .htaccess file within /img/ and use the following;
RewriteRule (.*)\.(gif|jpg|png)$ http://www.example-b.com/img/uploads/$1.$2 [R,L]
(Is this a good solution? Will there be any draw backs?)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread