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

PDF Files Shows 404 WordPress

Hello all.

I've been trying to crack my head figuring this out.

I'm a novice anyways so I thought I could reach out for some help.

I recently migrated my website to a new hosting.
Everything seems to be in order except this page which displays a bunch of different PDF files for download.

They are uploaded via media gallery.

These PDF's are displayed on a page with thumbnails so users can select which file they would like to download.

But when I click on anyone of them, i get a 404.
However, all i have to do is to copy the link at my browser navigation bar and hit enter or even simply copying the link and pasting it in a tab.
The download will then begin.

The staging site where it was hosted at before migration works fine and does not have all these problems.

IMPORTANT:

The staging site is still working just fine. After migration to a new host is when it all seems to fall apart.

I have tried messing around with the .htaccess files and nothing seems to work.
I'm comparing the code with the staging site to the live one and most things are similar.
I'm kinda lost.

Any help would be much appreciated.

Answers (4)

2016-03-18

Reigel Gallarde answers:

can you we see your site?


aaronwp comments:

Yes.

You can see the difference between the staging which works fine
http://spanco.frizzle.my/community/prihatin-newsletter/

and the after migration where it doesnt work like its supposed to anymore
http://www.spanco.com.my/community/prihatin-newsletter/


Reigel Gallarde comments:

looks good to me.. on both sites... can you give me a specific pdf that's not working?


aaronwp comments:

The first link works fine.

Its the 2nd link (http://www.spanco.com.my/community/prihatin-newsletter/) after migration that gives a 404.

Just click on any of the magazines and it will direct you to a 404 page.

But once u copy that link and paste it on ur browser, it seems to download.


Reigel Gallarde comments:

can you not try forcing it to download??

in your .htaccess file, add this...

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


aaronwp comments:

Doesn't seem to work.

# 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

# BEGIN Hotlinking
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://spanco.com.my/.*$ [NC]
RewriteRule \.(pdf|doc|docx|odt|rtf|txt)$ [R=302,L]
</IfModule>

# END Hotlinking

# BEGIN Force Download
AddType application/octet-stream .pdf .txt

<FilesMatch "\.(?i:pdf)$">

# Force File Download

ForceType application/octet-stream

Header set Content-Disposition attachment

</FilesMatch>

2016-03-18

Navjot Singh answers:

From the looks of it, your uploads directory still has some missing files. Try copying the uploads directory again.


aaronwp comments:

Files are not missing from directory.

Click any of the magazines from this link
http://www.spanco.com.my/community/prihatin-newsletter/

Once they take u to a 404, just copy the same link and paste it in a new tab.
It will start downloading.

Thats the problem.

I'm not sure if its a configuration issue.


Navjot Singh comments:

Seems like your query has been resolved. Please close and vote for it.

2016-03-18

Rempty answers:

Change this line
RewriteCond %{HTTP_REFERER} !^http://spanco.com.my/.*$ [NC]

to

RewriteCond %{HTTP_REFERER} !^http://www.spanco.com.my/.*$ [NC]


aaronwp comments:

I think you got it!

2016-03-18

2510506 answers:

please check pm