How can sensitive content such as images and PDF files be integrated into a PHP webpage without being accessible to search engines and bots?

Sensitive content such as images and PDF files can be integrated into a PHP webpage without being accessible to search engines and bots by storing the files outside of the web root directory and using PHP to serve the content dynamically. This way, the files are not directly accessible via URLs, making them more secure.

<?php
// Define the path to the sensitive content directory
$sensitiveContentDir = '/path/to/sensitive/content/';

// Get the file name from the URL parameter
$fileName = $_GET['file'];

// Check if the file exists in the sensitive content directory
if (file_exists($sensitiveContentDir . $fileName)) {
    // Set the appropriate content type header
    header('Content-Type: ' . mime_content_type($sensitiveContentDir . $fileName));
    
    // Output the contents of the file
    readfile($sensitiveContentDir . $fileName);
} else {
    // Handle file not found error
    echo 'File not found';
}
?>