How to redirect PDF files in WordPress without breaking old links

AuthorAuthor
Integriti StudioDecember 16, 2025

Issue Background

A client needed to update a PDF stored in their Media Library. The problem? Changing the filename would break every instance where that file had been shared, including old URLs and direct links on their website or other web pages.

For example: /wp-content/uploads/2024/02/old-document.pdf /wp-content/uploads/2025/03/updated-document-v2.pdf

Most WordPress hosts and FTP servers would not process redirects for static files like PDFs. Redirects usually work for pages, posts, or attachment pages, but not media assets directly.

Diagnosis

Standard redirect plugins, server settings, or regular expression rules couldn’t handle this scenario. The fix required a creative solution at the server and WordPress level—one that works with WordPress, handles PDF file URLs, preserves SEO, and allows visitors to access the new PDF automatically.

Solution

✔️ Step 1: Rename the Old File

Using SFTP, FTP, or your hosting file manager, locate the original PDF in the upload folder and rename it, like this: old-document-old.pdf

✔️ Step 2: Create a “Fake” Directory

Inside the same folder, create a directory using the exact same name as the old file (yes—with the .pdf extension): /wp-content/uploads/2024/02/old-document.pdf/

✔️ Step 3: Add a Redirect File

In that new folder, create an index.php file containing this redirect code:

php

CopyEdit

<?php header(“HTTP/1.1 301 Moved Permanently”); header(“Location: /wp-content/uploads/2025/03/updated-document-v2.pdf”); exit(); ?>

Now, whenever someone clicks the old PDF link, they’ll land on your new, updated version automatically.

Why It Works

➡️ Browsers try to load /old-document.pdf but find a folder instead. ➡️ That folder serves the index.php, which executes a to your new file. ➡️ No broken links. No SEO losses. Just clean user experience.

Final Outcome

✔ No need to manually update old links on your website—or anywhere else. ✔ Users go directly to your new document. ✔ Search engines respect the , maintaining SEO continuity.

Need help improving your WordPress forms or custom workflows? We build clean, reliable, and growth-driven WordPress solutions —without breaking a sweat.

Let’s Talk

Share

Other Resources Post

Building Loyalty Programs With Shopify Apps 

Summary A well-structured Shopify loyalty program or loyalty system can turn first-time customers into lifelong brand advocates. With Shopify’s ecosystem, you can easily launch points-based rewards, referral programs, and VIP...

Using Shopify Flow To Automate Your Store

Summary Shopify Flow is a powerful automation tool designed for Shopify Plus merchants that helps Shopify businesses streamline everyday tasks without writing code. From managing inventory and inventory levels to...

Adding Metafields In Shopify For Better Product Customization

Summary Metafields in Shopify allow you to store and display custom information beyond Shopify’s default fields. Whether it’s product specs, size charts, care instructions, or downloadable guides, metafields let you...