dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Loading images from another server with a relative path

  1. #1
    Join Date
    May 2007
    Posts
    104

    Loading images from another server with a relative path

    Hello,

    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.

    Thanks

  2. #2
    Join Date
    May 2007
    Posts
    104
    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!

  3. #3
    Join Date
    May 2007
    Posts
    104
    I've found a solution that seems to work...

    Create a seperate .htaccess file within /img/ and use the following;

    #URL redirection
    Options +FollowSymLinks
    RewriteEngine on

    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?)

    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles