Ask your WordPress questions! Pay money and get answers fast! (more info)

Link to PDF leads to 404 page when logged out WordPress

I'm currently stumped on an issue I'm experiencing on a site currently in development.

When trying to access PDFs on the site, I'm receive a 404 error when I'm not logged in.
However, when I log into the site, the PDF links work fine.

Any insights into what might be causing this issue would be appreciated.

<strong>.htaccess file</strong>
AddHandler php-stable .php

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

# protect wp-config.php
<files wp-config.php>
order allow,deny
deny from all
</files>

# protect htaccess
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 2 days"
ExpiresByType text/css A2592000
ExpiresByType text/plain A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType image/icon A2592000
ExpiresByType application/x-ico A2592000
ExpiresByType application/ico A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript A2592000
</IfModule>

# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Answers (3)

2013-04-24

Arnav Joy answers:

i do not think so it is problem of htaccess , can you show me link or provide access to your site ?


Michael Brumm comments:

I will send a link to your email... Trying to keep the link under wraps until we launch.


Arnav Joy comments:

try activating twentyeleven theme and then check if this problem still exists


Michael Brumm comments:

I activated the latest version of the "twentyeleven" theme and had the same issues... Still going to 404 page for logged out users.


Arnav Joy comments:

do you have any plugin installed that may cause this problem ?


Michael Brumm comments:

I just deactivated all of the plugins and it still persists... The client had installed the "[[LINK href="http://wordpress.org/extend/plugins/custom-permalinks/"]]Custom Permalinks[[/LINK]]" plugin recently... I deactivated and uninstalled that plugin.


Arnav Joy comments:

use htaccess with only following code


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


if that does not works then try to see any other media type like image and check if it also creating same problem or not


Michael Brumm comments:

Plugins installed:

- [[LINK href="http://adminmenueditor.com"]]Admin Menu Editor Pro[[/LINK]]
- [[LINK href="http://www.bizible.com"]]Bizible[[/LINK]]
- [[LINK href="http://eskapism.se/wordpress/cms-tree-page-view/"]]CMS Tree Page View[[/LINK]]
- [[LINK href="http://pippinsplugins.com/easy-content-types/"]]Easy Content Types[[/LINK]]
- [[LINK href="http://pippinsplugins.com/ecpt-filter-by-taxonomy-add-on/"]]Easy Content Types: Filter by Taxonomy[[/LINK]]
- [[LINK href="http://wordpress.org/extend/plugins/related-links/"]]Related Links[[/LINK]]
- [[LINK href="http://www.sean-barton.co.uk/wordpress-welcome-email-editor/"]]SB Welcome Email Editor[[/LINK]]
- [[LINK href="http://www.ericmmartin.com/projects/simplemodal-login/"]]SimpleModal Login[[/LINK]]
- [[LINK href="http://wordpress.org/extend/plugins/salesforce-wordpress-to-lead/"]]WordPress-to-Lead for Salesforce CRM[[/LINK]]
- [[LINK href="http://yoast.com/wordpress/seo/#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wpseoplugin"]]WordPress SEO[[/LINK]]


Michael Brumm comments:

I deleted the .htaccess and reset permalinks to create the default .htaccess file.

I also placed both a PDF file and Image file (both imported via media)... The image opens up fine when clicking on it, but the PDF still goes to the 404 page.

Hmm...

2013-04-24

Romel Apuya answers:

Hi,

I can help with this one.
Can you give wp-admin access to the site via PM..

cheers,

romel

2013-04-24

Daniel Yoen answers:

hello,

You upload PDF via FTP directly or via Media ?

:-)


Michael Brumm comments:

Files are uploaded via Media using the default directory structure (month- and year-based folders).


Daniel Yoen comments:

try to remove :

AddHandler php-stable .php


Daniel Yoen comments:

and for forced download, you should add :

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


to .htaccess file

hope this help :-)


Michael Brumm comments:

Made both these updates... Still no dice.


Daniel Yoen comments:

try to reflush permalink

1. delete .htaccess file (don't forget to backup)
2. Select permalink to Default(wp-admin/options-permalink.php), click Save Changes
3. Select permalink you want and click Save Changes,

hope this help :-)


Michael Brumm comments:

Yeah, have tried that a couple of times... Still no luck.


Daniel Yoen comments:

link please :-)


Michael Brumm comments:

I found the culprit... a .htaccess file was place in the uploads directory to prevent hotlinking... I removed this file and the issue's been fixed.