When I embed an external HTTP
iframe into my HTTPS
page, I get a mixed content error message:
<iframe src="http://www.example.com/"></iframe>
To work around this limitation I'd like to echo the external page from my own domain. How should I do that?
Thanks!
Call the http
page with curl
(or any other lib), and print out the reponse into some div
(this div
will be instead of the iframe
).
Please attach your PHP
page (who contains the iframe
), if you want more direction...
proxy.php
<?php
$url = "http://url-of-iframe/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$response = print curl_exec($ch);
//in case that the page does not contains the <base> tag, then add it
$base = '<base href="http://www.base-of-iframe.com/" /><!--[if IE]></base><![endif]-->';
$response = str_replace("<head>", "<head>".$base, $response);
?>
page.html
<html><iframe src="https://www.yourServer.com/proxy.php"></iframe></html>
You must be sure that "http://url-of-iframe/"
is a trusted site! otherwise, he can load malicious content into your page!