Results 1 to 7 of 7
  1. #1

    remote file handling -- difficult q'

    Either really difficult to answer, or really easy...

    I am running multiple servers serving images, I would like everything to run through the same root domain. eg ( and

    I can't seem to do this without fopen, or otherwise reading the file from the second server. Which then uses the bandwidth from server two, as well as server one.

    Basically, i need a redirection that doesn't change the URL, except in the subdomain.

    This might be possible with .htaccess, but most of my trials have resulted in address bar changes.

    All help appreciated.

  2. #2
    Join Date
    Jul 2003
    I think a simple solution would be to install a load balancer so that requests are distributed between your servers.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  3. #3
    thanks for the reply. any guess as to how I would do that, what it would cost, etc?

  4. #4
    Join Date
    Oct 2004
    Złocieniec, Poland
    PLEASE NOTE THIS SHOULD NOT BE DONE THIS WAY - this is only my idea and i do not recomend to use it (beside it is VERY lame and files are still easy to retrive and real url easy to find)

    RewriteEngine On
    RewriteOptions MaxRedirects=100
    RewriteRule ^id(.*)$ img/image.php?id=$1 [L]
    RewriteRule ^(img)/(.*)$ img/$2 [L]
    RewriteRule ^.*$ /path/to/test.php [L]
    $image_id = str_replace("/webdir/", "", $_SERVER['REQUEST_URI']);
    $image_id = str_replace(".jpg", "", $image_id);
    function read(dataid) {

    if (!document.all) {
    objXml = new XMLHttpRequest();"POST", "id" + dataid,false);
    document.getElementById("test").innerHTML = objXml.responseText;
    } else {
    objXml = new ActiveXObject("Microsoft.XMLHTTP");"POST", "id" + dataid, true);
    objXml.onreadystatechange=function() {
    if (objXml.readyState==4) {
    document.all["test"].innerHTML = objXml.responseText;
    <body onload="read(<?php echo $image_id; ?>); return false;">
    function clickIE4(){if (event.button==2){return false;}}
    function clickNS4(e){if (document.layers||document.getElementById&&!document.all)
    {if (e.which==2||e.which==3){return false;}}}
    if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}
    else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}
    document.oncontextmenu=new Function("return false;")
    <div id="test">

    if ($_GET[id] == "1") {
    echo '<img src="">';
    else {
    echo 'no image found';
    and thats it - as i said it is lame - ppl with some knowledge will be able to understand it and get right links grab files etc etc
    for average user it will be like a big "WoW"
    ofcourse netscape/mozilla/firefox user will be able to see real url when they click tools->website information->media

    but i dont know any pure nice looking way to use mod_rewrite or anything else than fopen (or similar) you mentioned
    and this solution is always something - certainly better than nothing

  5. #5
    Join Date
    Oct 2004
    Złocieniec, Poland
    alo there are some limitation: users must have javascript enabled, also it wont work (probably) for Opera users but will work pretty nice for Mozilla/Firefox and IE5 and up users

    ok so maybe a little explanation:
    you open website www.mywebsite/webdir/1.jpg
    mod rewrite will redirect it to test.php script
    it will use xmlhttprequest to open content of www.mywebsite/webdir/id1
    mod rewrite will redirect it to
    image.php will answer to xmlhttprequest something like <img src=somewhere/image.jpg>
    and it will write it to <div id=test>
    but users will not see it in sourcecode

    ofcourse if someone know how it work then he can access
    www.mywebsite/webdir/id1 directly and he will see outputed <img ....> in sourcecode

    to prevent that you can use simple one-time key generation but it is long story and i dont have time to explain that now unfortunately

    beside it is still very LAME and i dont see any reason to hide real urls

  6. #6
    hiding isn't the word I would use.

    When people upload images to my site i give them a one time url. It is common for me to have to change these urls when i change servers, etc.

    I feel that a redirect is lame. I've been looking into it, and I may be able to do a direct dns change to point a subdomain to a different webhost entirely. That would be the most efficient way, i believe.

  7. #7
    Join Date
    Oct 2004
    Złocieniec, Poland
    if you are able to do that (proboably yes) then it seems to be the best way - family business, small travel agency in Poland

Posting Permissions

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