I used to serve PDF files as static file:
and PDF files perfectly indexed by Google and other search engines. Then I decided to change my structure to place pdf files outside public folder, and then make them downloadable through PHP as
The PDF files with the new structure have not been indexed by search engines.
From SEO point of view, is it better to serve PDF files as static files, rather than making them downloadable through a PHP script?
The script looks like
header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$filename.'"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit;