Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
2  
Depends on your web server or app server, whatever. –  devnull Jul 23 '13 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? –  Oliver Salzburg Jul 23 '13 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. –  Oliver Salzburg Jul 23 '13 at 10:26
1  
Cool URIs don't change. –  Michael Kjörling Jul 23 '13 at 13:57

1 Answer 1

  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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.