In WordPress, updating the filename of a PDF file can create broken links across your site and external locations where the old PDF URL was shared. Standard redirect plugins and server redirects often don’t support media file redirects. This guide explains a clever workaround that allows you to redirect an old PDF URL to a new one without breaking any existing links.
Issue Background
A user wanted to update the filename of a PDF file in their WordPress Media Library. However, they were concerned that changing the file name would break links across their website and third-party platforms where the original URL had been shared.
Example:
Old PDF URL: /wp-content/uploads/2024/02/old-document.pdf
New PDF URL: /wp-content/uploads/2025/03/updated-document-v2.pdf
Most WordPress hosting environments do not support native redirects for static files like PDFs. Redirect rules usually apply to page URLs, not media files.
Diagnosis
Freshy’s team confirmed that a standard redirect would not work for this request. Instead, they implemented a reliable and creative workaround using basic file structure changes and PHP.
Resolution Steps
Step 1: Rename the Original File
Via SFTP or File Manager:
- Locate the old PDF in
/wp-content/uploads/2024/02/. - Rename the original file to something like:
old-document-old.pdf
Step 2: Create a Directory Named After the Old File
In the same directory:
- Create a folder with the exact name of the old PDF file:
/wp-content/uploads/2024/02/old-document.pdf/
Yes, you are creating a directory with .pdf as the folder name.
Step 3: Add a Redirect File
Inside the newly created .pdf folder:
- Create a file named
index.php. - Add the following code inside
index.php:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: /wp-content/uploads/2025/03/updated-document-v2.pdf");
exit();
?>
This PHP file will now serve a 301 Redirect when someone visits the old PDF URL, sending them automatically to the new file.
Final Outcome
With this solution in place:
- Any users visiting the old PDF URL will be redirected to the updated file.
- No external or internal links need to be updated.
- SEO value and user experience are preserved.
Why This Fix Works
WordPress and most hosting environments treat media files like static assets — they cannot be redirected easily. By converting the old PDF “file” into a folder containing an index.php file, you effectively hijack the request and send users to the new file.
This technique is especially useful when:
- You cannot edit all locations where the old file URL was shared.
- You want to maintain seamless user experience.
- You want to implement a permanent (301) redirect for SEO purposes.
Need Help Managing WordPress Media and Redirects?
If you need help managing PDF files, media URLs, or advanced redirect solutions in WordPress, Freshy’s expert team can assist. Contact us today to get seamless, professional support.