Mod rewriten- Get photos from domain B while they are on domain A

Discussion in 'Programming' started by glink1, Apr 20, 2008.

  1. #1
    Hi

    I have shared hosting account
    with two subfolders for each domain.

    Domain B is test(beta) page where i do new stuff before
    i publish it on site A.

    Site A and B have same database where i store file names of photo.

    I want to access photos that are on site A from domain B

    ex.
    Get /public_html/A/photos/sample.jpg (http://A.com/photos/sample.jpg)
    by entering url
    http://B.com/photos/sample.jpg
     
    glink1, Apr 20, 2008 IP
  2. Rob Whisonant

    Rob Whisonant Well-Known Member

    Messages:
    156
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Not sure if this will work in htaccess. If not put it in your Apache conf file.

    First try it in htaccess on site B.

    Alias /A/photos /home/httpd/siteB/public_html/A/photos

    Re's
    Rob Whisonant
     
    Rob Whisonant, Apr 20, 2008 IP
  3. Rob Whisonant

    Rob Whisonant Well-Known Member

    Messages:
    156
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Of course change the path to fit your site details on the server.

    Re's
    Rob Whisonant
     
    Rob Whisonant, Apr 20, 2008 IP
  4. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #4
    Because both domains are hosted on the same server under your account.
    You want to grab photo from B, and display it to A. :
    1. Create a PHP file (e.g. display.php) in A,
    2. Read the file content from B's real path with fopen or any file reading method, store the content in a variable (e.g. $fileContent).
    3. Echo the header in display.php with related content type. For example.
      header('Content-type: image/gif');
      PHP:
    4. Echo the file content.
      $fileContent
      PHP:

    Now when a user opens display.php in A, the B's photo will be displayed.
    Now you must make a mod rewrite so that the user opens display.php as display.jpg, display.gif or any alias that you like :)

    If A and B are not hosted in the same server, read the B's photo with cURL.
     
    xrvel, Apr 21, 2008 IP
  5. Rob Whisonant

    Rob Whisonant Well-Known Member

    Messages:
    156
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Rob Whisonant, Apr 21, 2008 IP