Is there a way to redirect from a direct PDF link?

Our marketing dept sent out an email with dozen of PDF's. We sent out an email containing HTTP links to PDF documents that are hosted on our server.

We now are moving the destination to another location.

current settings:

  • Apache/2.2.24
  • PHP 5.3.24

  • is it possible to redirect the destination without sending the email again to all recipients?

My current .htaccess looks like this (in the root of the file folder)

<IfModule rewrite_module> RewriteEngine On Redirect /9/91/Demo.pdf RewriteCond %{QUERY_STRING} \.[^\\/:*?\x22<>|%]+(#|\?|$) [nocase] RewriteRule . - [forbidden]
</IfModule>
  • But I always get the Demo.pdf file

If I want to redirect: to --->

what should be the command?

4

2 Answers

  1. In the root of your documents folder of the webserver, place a new .htaccess file (or modify the existing one, if you've already created one in the past).

  2. For every .pdf document, place a line in the .htaccess file with the following syntax:

    Redirect 301 /pdf/some-document.pdf 

The Redirect directive requires mod_alias to be loaded (it usually is).

The 301 indicates that this is a permanent redirection (in contrast to 302, which would be a temporary redirection). After that is the old path of the document (relative to the location of the .htaccess file). And the last argument is the new location of the file.

Be sure to restart Apache after adjusting the .htaccess file, as it is most likely cached.

Create a folder with name as "oldfile.pdf" create an index.php file in it and add this code:

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " );
?>

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like