[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Force the download of PDF from third party URL using mod_rewrite or similar

Posted on 2010-08-24
8
Medium Priority
?
459 Views
Last Modified: 2012-05-10
We have a CDN provider that provides PDF files though for some reason they do not progressively download as they would if being download by a Apache web server. There is not a way from the CDN side of providing a method to force downloading of files rather then opening by default. I can handle this in Apache if the file were hosted locally by using:
AddType application/octet-stream .pdf

Open in new window

or
<FilesMatch "\.(?i:pdf)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>

Open in new window

but we are not hosting the file but instead providing a redirect to the CDN. Is there a way to force a redirected link to download rather than open? Below is our current rewrite rule which in short takes any requested file in the dl directory and requests it from the CDN. Can we control the remote behavior?

RewriteRule ^/dl/(.*)$ http://c0002.cdn1.cloudfiles.rackspacecloud.com/$1 [R=302,L]

Open in new window

0
Comment
Question by:adamshields
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 9

Expert Comment

by:fcontrepois
ID: 33520218
You should use mod_proxy to change the headers
0
 
LVL 3

Author Comment

by:adamshields
ID: 33520307
Can you elaborate or provide an example?
0
 
LVL 9

Expert Comment

by:fcontrepois
ID: 33520515
Hi,

let the browsers download the pdf from you and you creating a redirection to the remote host and supply the right header.

The idea is to use the following directives, probably with some tweak


ProxyPass /dl/ http://c0002.cdn1.cloudfiles.rackspacecloud.com/
+
AddType application/octet-stream .pdf





0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Author Comment

by:adamshields
ID: 33520656
Would this effect the CDN caching or speed since it has to proxy through my host?
0
 
LVL 9

Accepted Solution

by:
fcontrepois earned 2000 total points
ID: 33520772
All requests - particularly download - would go through your host, so if you use the cloud for bandwidth then this is not a good solution. If you choose cloud for space then yes.

The "problem" is by redirecting (301)  the browser to rackspace you loose control on the requests for pdf.
0
 
LVL 3

Author Comment

by:adamshields
ID: 33520825
That's what I was thinking. We are using it for bandwidth in this scenario. Guess we'll stick with ZIP files as the CDN properly prompts for download. Unless you can think of any  other workarounds?
0
 
LVL 9

Assisted Solution

by:fcontrepois
fcontrepois earned 2000 total points
ID: 33523171
After receiving a 301 the browser will just create a new request to the 301 destination so you don't have any possibilities to change anything, it's between them.
0
 
LVL 3

Author Closing Comment

by:adamshields
ID: 33524165
Thanks for the insight.
0

Featured Post

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question