Loading external webpage into my page without redirecting to different URL

44,723

Solution 1

You can use either an Iframe, or file_get_contents();

Iframe:

<iframe src="http://google.com" style="width: 100%; height: 100%;">

file_get_contents():

<?php
echo file_get_contents('http://google.com');
?>

With file_get_contents(), you need to beware of the website you're fetching from using relative URL's, which will break the CSS, Images, Javascript, etc.

Solution 2

You are not going to be able to use php's include function, as this is not a resource residing on your server.

One option you could explore is loading everything in as the contents of an iframe: see http://www.w3schools.com/tags/tag_iframe.asp for some details about the iframe html element

Share:
44,723
Jordan.J.D
Author by

Jordan.J.D

Always growing.

Updated on July 05, 2022

Comments

  • Jordan.J.D
    Jordan.J.D almost 2 years

    So what I want to do is create a subdomain on my website and have it load an external website into it without actually going to that website. For instance:

    google.mydomain.com loads google.com but the URL bar reads google.mydomain.com.

    How do I go about doing this?

    I tried this but could not figure it out.

    Trying:

    iframe

    1. I want page to take up the whole screen for each person's computer. Can I set it to 100% instead of x amount of pixels?

    2. I want to remove scroll bars but it says not supported.

  • Jordan.J.D
    Jordan.J.D about 11 years
    Absolutely perfect thank you! Just need to remove scrolls if possible, but it is barely noticeable.
  • Connor Gurney
    Connor Gurney about 11 years
    Good! On the Iframe, you can use something like scrolling="no" or embed something in the CSS, such as iframe { overflow: hidden; }
  • Jose Enrique Calderon
    Jose Enrique Calderon over 4 years
    How may I do this in a wordpress page?
  • RedDragonWebDesign
    RedDragonWebDesign almost 4 years
    I looked it up. <iframe> is still supported in HTML5.