How to 301 redirect a pdf file in htaccess

Here’s some quick information on how to use an Apache .htaccess file to do a 301 redirect with either mod_rewrite or mod_alias. This method should also work for .doc and .docx files as well.

mod_rewrite

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/old/path/file.pdf$
RewriteRule ^(.*) /new/path/file.pdf [L,R=301]

mod_alias

Redirect 301 /old/path/file.pdf /new/path/file.pdf

Leave a Comment

Your email address will not be published. Required fields are marked *