Jump to content

Masking Hiding Image URLs?


upperbid

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

hi i think this could help you out. :P

 

<?
//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;


?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.