404 Crawl Error to almost all pdf files

by Chris   Last Updated May 21, 2018 20:04 PM

The website is built in wordpress.

I do not have than much experience, so I need your help. Once I entered at “Search Console” at “Crawl Errors” tab I saw that all “404 errors” are in “wp-content/uploads” and most of them are .pdf
I noticed than it adds text after the suffix of .pdf.

1st example:
At “Crawl error” it appears “Error 404” on this link : https://example.com/wp-content/uploads/2016/10/salon-du-livre-octobre-2016_2-2.pdf;salon-livre-octobre-2016_2-2
When I try to get in, it says “File not found”
If I delete the suffix “;salon-livre-octobre-2016_2-2” from the link then I have access to .pdf. The link will be : https://example.com/wp-content/uploads/2016/10/salon-du-livre-octobre-2016_2-2.pdf (it is correct)

2nd example:
If I delete the symbol of “;” at the suffix then the link works

I tried to redirect with Yoast.

1st attempt:
Old URL: https://example.com/wp-content/uploads/2016/10/salon-du-livre-octobre-2016_2-2.pdf;salon-livre-octobre-2016_2-2
New URL: https://example.com

2nd attempt:
Old URL: https://example.com/wp-content/uploads/2016/10/salon-du-livre-octobre-2016_2-2.pdf;salon-livre-octobre-2016_2-2
New URL: https://example.com/wp-content/uploads/2016/10/salon-du-livre-octobre-2016_2-2.pdf

None of these 2 worked.

Is there any way to redirect these PDFs?
What can I do with the problem of “Crawl Errors”?

I'm using Attachment File Icons (AF Icons) plug in for pdf by Praveen Rajan And All 404 Redirect to Homepage By Fakhri Alsadi

Thanks in advance.

enter image description here

Answers 1

To correct these crawl errors and redirect to remove the part after and including the semicolon (;) then you can do something like the following near the top of your .htaccess file:

RewriteRule ^(wp-content/uploads/[^;]+\.pdf); /$1 [R=302,L]

This must go before the WordPress front-controller, otherwise, it will have no effect (which may be part of the problem you are facing).

Change the 302 (temporary) redirect to 301 (permanent) only once you have tested to make sure this works OK.

However, as to why these crawl errors appeared in the first place is another matter - and this may still require your attention.

May 22, 2018 17:41 PM

Related Questions

Updated June 22, 2018 03:04 AM

Updated July 05, 2018 14:04 PM

Updated July 26, 2018 20:04 PM

Updated June 19, 2017 10:04 AM