Ok, there could be a few solutions to the problem. First is assuming you know how to use Media Library and correctly link to a file and your still getting the error my hunch is that it’s the .htaccess file. If not and your a real novice try this: https://www.youtube.com/watch?v=XJFIbd6wN0A&feature=related
Also, see my post re this issue: https://www.ads-software.com/support/topic/357445?replies=10
For me, the problem was related to permalinks and the .htaccess file which was calling for a 404 error page instead of accessing the file. So wordpress — or at least a faulty .htaccess — was effectively “blocking” access to files. After a long talk with tech support at the site host, and looking through error logs, trying a few things here and there, we determined it was indeed the .htaccess file.
So I deleted the .htaccess file after removing permalink settings and the files loaded. But this caused a few other issues with pages not being found etc. So rewrote the .htaccess file (see below).
Plus, the .htaccess file is what’s responsible for generating the 404 error page in the first place which I didn’t know and would have helped me narrow down the problem in the first place. Here’s a good link re .htaccess: https://www.freewebmasterhelp.com/tutorials/htaccess/
So here, from the codex, I think is the root of the problem:
Using only %postname%
If using version 2.0 or greater, the following is no longer true as this has been changed.
If you use postname as the only element in your permalinks to create a structure such as example.com/post-title, the rewrite rules may make it impossible to access pages such as your stylesheet (which has a similar format) or the /wp-admin/ folder . It’s best to include some numeric data (e.g. the post ID or date) in the permalink to prevent this from happening. Additionally, WordPress v1.2.x requires the use of a date structure in order for some features, such as the calendar, to function properly. /%year%/%monthnum%/%day%/%postname%/ is always a good start.
You can get past the above issue and continue using %postname% if you make a simple change to your .htaccess file as below:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^wp-content.*
RewriteCond %{REQUEST_FILENAME} ^wp-admin.*
RewriteCond %{REQUEST_FILENAME} ^wp-include.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Simply the conditions now say do not apply the rule if the file name includes the word press content, admin or include directory. This now allows you to get to the admin area with no issues as well as content.
Which is from the codex here: https://codex.www.ads-software.com/Using_Permalinks And don’t say ” Should’ve read the codex first”, because I would have if I could have isolated the problem to the .htaccess file initially.
Thing is, my .htaccess file didn’t include the #BEGIN and #END WordPress. Which is my best guess as to why it was preventing access to files uploaded with Media Library.
If you haven’t changed your permalinks settings it’s possible something else has tinkered with your .htaccess file and it’s the same problem. So I would try rewriting it anyway. And change the permissions to 666 so wordpress can write to it afterward.
I found a few of the images were still not working so I had to go back and reload them with media library. It worked.
So I hoped that helps anyone else who seems to be having this problem.
I look forward to any feedback on this issue, e.g. why exactly is it that using only /%postname%/ as your permalink structure restricts access to some files????
Anyway all the best, keep up the good work wordpress team!