4

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 http://www.cnn.com/index.html
     RewriteCond %{QUERY_STRING} \.[^\\/:*?\x22<>|%]+(#|\?|$) [nocase]
     RewriteRule . - [forbidden] 
</IfModule>
  • But I always get the Demo.pdf file

If I want to redirect: www.site.com/files/somefile.pdf to ---> www.othersite.com/otherfiles/correctfile.pdf

what should be the command?

4
  • 2
    Depends on your web server or app server, whatever.
    – devnull
    Jul 23, 2013 at 9:16
  • 1
    I'M assuming they've sent out an email containing HTTP links to PDF documents that are hosted on some server? Jul 23, 2013 at 9:52
  • 2
    This depends mostly on the web server you're using (like IIS, Apache, ...). Knowing that, it shouldn't be a problem to implement a redirect from one URL to another. Jul 23, 2013 at 10:26
  • 1
    Cool URIs don't change.
    – user
    Jul 23, 2013 at 13:57

2 Answers 2

7
  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 http://example.com/foo/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.

0

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: http://www.example.com/new-page-to-redirect-to.pdf" );
?>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .