
- Image via Wikipedia
If you have the oportunity to include remote file includes, then you should jump at the opportunity.
Why?
Well, you get full content indexation of any HTML that you can incorporate on your page, whereas you get none if all you can include is a link to a remote javascript option.
Unfortunately, more and more ISPs are disabling remote file includes and only permitting your own server side includes.
What if you could embed pure HTML in your own site and get full SEO credit, even for javascript?
This has been causing a headache for me; I understand the potential security concerns around running remote scripts, but I want to get the SEO benefits of displaying the pure content HTML on my site.
I have been digging around and found that the php command fsock_open() holds the key.
It is possible to use fsock_open() in any environment where you can use PHP to bypass the constraints of having remote file includes disabled.
In fact, I have realised that it actually allows me to generate pure HTML from remote scripting and get full SEO recognition.
Please have a look at http://www.foodwithpassion.co.uk/testing/test.php. The first example of the Affiliate Window content unit is generated from pulling the generated HTML from the remote PHP (otherwise) include file.
The second version is from generating HTML from a remopte javascript file.
Both now give me full SEO credit by including the generated HTML on that page (view source if you don’t believe me).
Is it difficult to achieve …. hell, NO!!
You need to create a new function in your site code (remember to include the functions script) as follows (remove spaces in opening and closing php <> statements:
< ? php
//create the function to use fsock_open() ilo remote php include.
function remote_include($url, $range = 0)
{
$url_stuff = parse_url($url);
$port = isset($url_stuff['port']) ? $url_stuff['port'] : 80;
$fp = @fsockopen($url_stuff['host'], $port);
if (!$fp)
return false;
$query = 'GET '.$url_stuff['path'].'?'.$url_stuff['query']." HTTP/1.1\r\n";
$query .= 'Host: '.$url_stuff['host']."\r\n";
$query .= 'Connection: close'."\r\n";
$query .= 'Cache-Control: no'."\r\n";
$query .= 'Accept-Ranges: bytes'."\r\n";
if ($range != 0)
$query .= 'Range: bytes='.$range.'-'."\r\n"; // -500
//$query .= 'Referer: http:/...'."\r\n";
//$query .= 'User-Agent: myphp'."\r\n";
$query .= "\r\n";
fwrite($fp, $query);
$chunksize = 1*(1024*1024);
$headersfound = false;
while (!feof($fp) && !$headersfound) {
$buffer .= @fread($fp, 1);
if (preg_match('/HTTP\/[0-9]\.[0-9][ ]+([0-9]{3}).*\r\n/', $buffer, $matches)) {
$headers['HTTP'] = $matches[1];
$buffer = '';
} else if (preg_match('/([^:][A-Za-z_-]+):[ ]+(.*)\r\n/', $buffer, $matches)) {
$headers[$matches[1]] = $matches[2];
$buffer = '';
} else if (preg_match('/^\r\n/', $buffer)) {
$headersfound = true;
$buffer = '';
}
if (strlen($buffer) >= $chunksize)
return false;
}
if (preg_match('/4[0-9]{2}/', $headers['HTTP']))
return false;
else if (preg_match('/3[0-9]{2}/', $headers['HTTP']) && !empty($headers['Location'])) {
$url = $headers['Location'];
return http_get($url, $range);
}
while (!feof($fp) && $headersfound) {
$buffer = @fread($fp, $chunksize);
echo $buffer;
ob_flush();
flush();
}
// $status = fclose($fp);
// return $status;
}
? >
Simply echo the remote HTML using the following code wherever you would like the output to appear:
echo remote_include(‘remote_url’); for a PHP include, and
echo ‘‘;
for remote javascript.
Of course, this only works anywhere that you are allowed to run PHP, but it is a great step forward to include HTML wherever you can.
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_a.png?x-id=066b4e8e-a43b-4d55-b238-35bd72032905)

{ 3 trackbacks }
{ 1 comment… read it below or add one }
that makes improves on the page SEO, and finally i got it worked out with a very simple solution. anyone have any reservations about pulling the pure HTML on-page. thanks for the info