Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 3rd Aug 2012, 06:26 PM   #1
WordPress Developer
War Room Member
 
Jeremy Lebre's Avatar
 
Join Date: 2012
Posts: 27
Thanks: 3
Thanked 4 Times in 3 Posts
Default
How to prevent your PDF files from opening in a web browser...
Share on: 
fb share twitter share gplus share more share

Normally, when clicking on a link to a pdf file, the file opens within
the web browser window.

To prevent this, your host must support URL rewriting via htaccess.
Download the .htaccess file in the root directory of your website.
Download it in two copies in two different folders on your computer.
You will not modify one of these copies to undo your changes if
something goes wrong.

If you have no .htaccess file in that directory, simply create one.
Create a htaccess.txt file with a text editor like Notepad++. You
will only have to upload it to the root directory of your website
and rename it .htaccess.

In your .htaccess file (or htaccess.txt, depending on your situation),
add the following code:

Code:
<IfModule mod_headers.c>
<FilesMatch ".(pdf|zip)$">
ForceType application/octet-stream
Header set Content-disposition attachment
</FilesMatch>
</IfModule>
You can add other file extensions between the two parentheses.

Then upload your file to the root directory of your website, and
rename it .htaccess when necessary. Display your website with
your browser to make sure everything works well. In case of
problems, delete your .htaccess file or replace it with the original
version to undo your changes.

Jeremy Lebre is offline  
Unread 4th Aug 2012, 01:33 AM   #2
WordPress Developer
War Room Member
 
Jeremy Lebre's Avatar
 
Join Date: 2012
Posts: 27
Thanks: 3
Thanked 4 Times in 3 Posts
Default
Re: How to prevent your PDF files from opening in a web browser...
Share on: 
fb share twitter share gplus share more share

But I've no problem, jaasmit. My post is a solution.

Jeremy Lebre is offline  
Unread 4th Aug 2012, 07:55 AM   #3
Marketing 101 :)
 
Join Date: 2011
Location: London, UK
Posts: 314
Thanks: 19
Thanked 48 Times in 45 Posts
Default
Re: How to prevent your PDF files from opening in a web browser...
Share on: 
fb share twitter share gplus share more share

Jeremy, thank you for your post, this is very helpful/informative. thanks
Ninja Ana is offline  
Unread 22nd Aug 2012, 07:29 AM   #4
VIP Warrior
War Room Member
 
Join Date: 2006
Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
Default
Re: How to prevent your PDF files from opening in a web browser...
Share on: 
fb share twitter share gplus share more share

Why do you want to mess up how the user wants to display pdf files on their system?
KirkMcD is offline  
Closed Thread


Bookmarks

Tags
browser, files, opening, pdf, prevent, web


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 01:31 AM.