S
S
Sergey Nizhny Novgorod2016-02-19 06:19:28
Search Engine Optimization
Sergey Nizhny Novgorod, 2016-02-19 06:19:28

How to disable the file index on the site?

Good afternoon.
I place a file (book.txt) on my website, which is available via a direct download link for registered users. However, the search engine bypasses my site and displays my book directly in the search result (download link).
The link looks like site.ru/books/book.txt
How can I prevent such indexing of my book?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Shendakov, 2016-02-19
@Terras

I solved a similar problem of downloading pdf files only for registered users using the function:
[code]
...
function downloadFile( $infile, $mimetype='application/octet-stream')
{
$file = JPATH_BASE.DS.'images/pdf /'.$infile ;
if ( ! file_exists ( $file ) ) die('File '.$file.' not found ');
$from = $to = 0;
$cr = NULL;
if (isset($_SERVER['HTTP_RANGE']))
{
$range=substr($_SERVER['HTTP_RANGE'], strpos($_SERVER['HTTP_RANGE'], '=')+1);
$from=strtok($range, '-');
$to=strtok('/'); if ($to>0) $to++;
if ($to) $to-=$from;
header('HTTP/1.
$cr='Content-Range: bytes' . $from. '-' . (($to)?($to . '/' . $to+1):filesize($file));
} else header('HTTP/1.1 200 Ok');
$etag=md5($file);
$etag=substr($etag, 0, 8) . '-' . substr($etag, 8, 7) . '-' . substr($etag, 15, 8);
header('ETag: "' . $etag . '"');
header('Accept-Ranges: bytes');
header('Content-Length: ' . (filesize($file)-$to+$from));
if ($cr) header($cr);
header('Connection: close');
header('Content-Type: ' . $mimetype);
header('Last-Modified: ' . gmdate('r', filemtime($file)));
$f = fopen($file, 'r');
header('Content-Disposition: attachment; filename="' .basename($file) . '";');
if ($from) fseek($f, $from, SEEK_SET);
if (!isset($to) or empty($to)) {
$size=filesize($file)-$from;
} else {
$size=$to;
}
$downloaded=0;
while(!feof($f) and !connection_status() and ($downloaded<$size)) {
echo fread($f, 512000);
$downloaded+=512000;
ob_flush();
flush();
}
fclose($f);
}
...
[/code]
Which is called when clicking on a link that is visible only to those who have the right to see it. The function actually gives the file itself, and not a direct link, as you have. You can do the same for other EPs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question