upperbid Posted December 15, 2009 Share Posted December 15, 2009 I own several websites on the same server and I want to use images in one folder for a second site, but not show the URL of where my images are coming from on the second site. In other words, say the original images are at firstsite.com in a folder called images. I want to display them also on a second site we can call secondsite.com but show the image URL as secondsite.com (not firstsite.com where they are really coming from). I am pretty sufficient at php, but I have not been able to figure out how to do this. Any help would be appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/ Share on other sites More sharing options...
trq Posted December 15, 2009 Share Posted December 15, 2009 Setting up an alias within apache would be the easiest solution if you have sufficient access to do so. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-977556 Share on other sites More sharing options...
upperbid Posted December 16, 2009 Author Share Posted December 16, 2009 Any other suggestions or help on this? Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978210 Share on other sites More sharing options...
oni-kun Posted December 16, 2009 Share Posted December 16, 2009 Any other suggestions or help on this? Nope. An Alias is all that'll do. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978213 Share on other sites More sharing options...
trq Posted December 16, 2009 Share Posted December 16, 2009 Any other suggestions or help on this? What other suggestions do you want? Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978214 Share on other sites More sharing options...
upperbid Posted December 16, 2009 Author Share Posted December 16, 2009 Hi Thorpe, I was hoping for something with a PHP solution, but I do have access to the server since I have the whole server, but I don't really know how to mask the image URL on the page so that it shows a different URL than the source. I've read posts about the access file but none of those worked when I tried them (my source is a different domain--though it is on the same server). Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978230 Share on other sites More sharing options...
oni-kun Posted December 16, 2009 Share Posted December 16, 2009 Hi Thorpe, I was hoping for something with a PHP solution, but I do have access to the server since I have the whole server, but I don't really know how to mask the image URL on the page so that it shows a different URL than the source. I've read posts about the access file but none of those worked when I tried them (my source is a different domain--though it is on the same server). You can always use a PHP resource file. Such as <img src='image.php?image=file.jpg'/> Retrieving thus masking it from the other url. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978232 Share on other sites More sharing options...
upperbid Posted December 16, 2009 Author Share Posted December 16, 2009 Hi Oni-Kun, I tried several of these solutions as well and I could not get them to work. I could get it to work when the source was on the same URL, but not coming from a different URL. Maybe I was doing something wrong, but I tried several different solutions I found in online posts and I just could not get them to work (but they were all talking about masking the image on your own URL). Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978239 Share on other sites More sharing options...
oni-kun Posted December 16, 2009 Share Posted December 16, 2009 Hi Oni-Kun, I tried several of these solutions as well and I could not get them to work. I could get it to work when the source was on the same URL, but not coming from a different URL. Maybe I was doing something wrong, but I tried several different solutions I found in online posts and I just could not get them to work (but they were all talking about masking the image on your own URL). Can't you just do.. image.php: <?php $file = $_GET['file']; echo "http://www.site1.com/images/". $file; ? It'll mask it if I'm right. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978242 Share on other sites More sharing options...
trq Posted December 16, 2009 Share Posted December 16, 2009 I do have access to the server since I have the whole server So you have a dedicated box but no idea how to administer it? I hope security isn't a concern. Simply put your images (for both sites) within a directory. example. /usr/share/siteimages Then, within both website vhost configurations place the following. Alias /img /usr/share/siteimages Now, when users access /img/foo/bar.jpg via the web it maps to /usr/share/siteimages/foo/bar.jpg on the filesystem. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978268 Share on other sites More sharing options...
upperbid Posted December 16, 2009 Author Share Posted December 16, 2009 Thorpe, The first site already has the files in a designated folder and I am not able to change that folder without a lot of script work, so I can't move the images. Any other suggestion? Oni-Kun, I tried what you suggested, but it doesn't work. It's similar to other posts I've found. The page where I post the <img src='image.php?image=file.jpg'/> does not display the image that would be found at the URL in the image.php file with the code below: <?php $file = $_GET['image']; echo "http://www.othersite.com/images/". $file; > I wish that worked, because that is what I'm looking for--a simple solution. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978306 Share on other sites More sharing options...
Deoctor Posted December 16, 2009 Share Posted December 16, 2009 hi i think this could help you out. <? //usage =<img src="/img.php?fl=filename&type=1" alt="Image"> $ext = $_REQUEST["type"]; $filename = $_REQUEST["fl"]; /* $img is the directory where all your images are stored */ $img = "images/"; /* Firstly let's see if the variables have information in them */ if (!$ext) { echo "Could not find appropiate information ext"; exit; } if (!$filename) { echo "Could not find appropiate information Filename"; exit; } if (!$img) { echo "Could not find appropiate information IMG"; exit; } /* Extensions should be shown as numbers in the url for good protection. We will now redefine $ext matching the appropiate number from requested variable "type" */ if ($ext == 1) { $ext = "jpg"; } else if ($ext == 2) { $ext = "gif"; } else if ($ext == 3) { $ext = "png"; } /* The filename is not shown as numbers so we now have the "ingredients" needed to show the image. Now lets see if the image exists */ if (!file_exists($img . $filename . "." . $ext)) { echo "Could not find image"; exit; } /* Now lets show the image. This is just a simple include statement */ include $img . $filename . "." . $ext; ?> Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978319 Share on other sites More sharing options...
upperbid Posted December 16, 2009 Author Share Posted December 16, 2009 Hi ym_chaitu, I already found this script in other posts on the web. I just tested it again and it doesn't work for what I'm trying to do. The image from the source (a different website) does not appear on the page. Like I said, I've looked around and spent quite a bit of time on this and so far, I have not found a script or any code that accomplishes this. Anybody can test it by trying to display any image from any site on their site with a the display of a different URL. If anyone figures out how to do this with PHP, please let me know. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978328 Share on other sites More sharing options...
trq Posted December 16, 2009 Share Posted December 16, 2009 The first site already has the files in a designated folder and I am not able to change that folder without a lot of script work, so I can't move the images. Any other suggestion? If you insist on keeping the first sites files in the same location simply point the alias within the second site to the location in the first. Of course, you could move them quite easily and write your aliases accordingly so that your scripts won't be disrupted, but I'm sure were not going understand that concept. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978363 Share on other sites More sharing options...
upperbid Posted December 16, 2009 Author Share Posted December 16, 2009 You know, Thorpe, your arrogance is ugly and your constant need to be critical of others in an attempt to make yourself look intelligent is annoying. These unnecessary statements: I'm sure were not going understand that concept. What other suggestions do you want? So you have a dedicated box but no idea how to administer it? show your true insecurity and some dire need to appear intellectual to others at the expense of others. As shocking as this may seem to you, I don't want your help, take your suggestions and arrogance to someone else. Believe it or not, I've done fine in server administration and programming long before you came along, as hard as that must be for you to believe. Quote Link to comment https://forums.phpfreaks.com/topic/185181-masking-hiding-image-urls/#findComment-978671 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.