Displaying content from another site

Discussion in 'PHP' started by knkk, Jun 18, 2010.

  1. #1
    I have 2 sites, example.co.in and example.com, hosted on 2 different servers (I have all access details for both).

    When someone accesses example.co.in/a/b.php?c=d, I want it to show the HTML of example.com/a/b.php?c=d

    This site has to be search-engine-friendly, so I do not want to use an iframe, or even AJAX, since all the content has to be in the HTML - basically, example.co.in/a/b.php?c=d should output just the same HTML as example.com/a/b.php?c=d would.

    I could use echo file_get_contents(example.com/a/b.php?c=d) in example.co.in, but that would mean a request goes from the example.co.in server to the example.com server, and then the output would come to the example.co.in server, which would then send it to the user. That could mean time delay, and also that I am using twice the bandwidth - since there is data transfer from both my servers.

    Apache rewrite will change the URL, which I do not want to happen - I want people who browse example.co.in to stay on it.

    I was wondering if any of the numerous experienced people on this forum would be able to suggest a solution :). Thank you very much for your time!
     
    knkk, Jun 18, 2010 IP
  2. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #2
    If you know PHP use CURL and file_get_contents to get all the data and pass through the DOM to rip data :)
     
    roopajyothi, Jun 18, 2010 IP
  3. knkk

    knkk Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, Roopa. The other site is also mine, so that isn't necessary :). I was looking more at some kind of solution where pages from the example.com load automatically when someone uses the correspondings URLs with example.co.in as the domain. I thought this in my .htaccess for example.co.in would work:

    
    <Location />
    	ProxyPass / http://www.example.com/
    </Location>
    
    Code (markup):
    But it's showing a 500 Internal Server Error. I'm thinking my server (it's shared) doesn't have mod_proxy installed. Would you have any idea if it's something else?
     
    knkk, Jun 18, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Oops! I can code you for that some bucks if you need

    BTW: I don't understand your last post clearly!
     
    roopajyothi, Jun 18, 2010 IP
  5. knkk

    knkk Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks, Roopa. What I meant is that I do not need to rip content from example.com to populate example.co.in, since both are my own sites (and also that my objective is that example.co.in/a/b/c=d should show the same content as example.com/a/b/c=d would). Thank you for your offer. I'll try a bit more, and then revert to you.
     
    knkk, Jun 18, 2010 IP