Use this if you want to upload a PDF to the WordPress media library but restrict access so that only visitors referred from a specific external page can view or download it.
Steps:
Upload the PDF to a protected folder (not directly in /wp-content/uploads/
).
Create a PHP script (pdf-proxy.php
) in your theme or child theme folder:
Link to the PHP file instead of the direct PDF URL.