Strange File/404 issues
-
Hi All,
When I add a picture using the media library and insert it as a thumbnail in a post it shows fine. However when I click on the image to load the full image I get a 404. Any ideas??
-
I had a similar problem once and discovered that the HTML in the theme SAID it was loading the photos to one directory, but really loaded them in another. Editing the code fixed it.
Well I know the files are being uploaded to the proper dir because they are there. I can log in via FTP and see them in wp-content/uploads.
Really strange that I can see the image as a thumbnail but when it points to the file itself I get a 404. The links are correct I have triple checked.
I’m really having trouble figuring out where I should even start looking to solve this problem.
If I upload a file with the Media Library it goes to wp-content/uploads. If I open the file in FTP it’s there, it’s fine, I copy the url directly from FTP and paste it in my browser and I get a 404. What’s up?? Any ideas?
It seems like wordpress is somehow blocking access to the files it uploads. Is this possible? Does that make sense?
Ok, so if I upload a file with the Media library and then click on the file in the dashboard it gives the file url. If i put this into the browser it should show the file right?
That’s what I thought but it’s not working. Any ideas?
well….it have you tried deactivating all plugins, and going back to default theme?
It seems silly, but plugins and themes can interfere with things it seems like they never should….
And then permalinks….again…it really doesn’t sound like it’s the issue….but….. I usually do the plugins, then the theme, then set my permalinks back to default and delete .htaccess
then with everything at default see if the problem remains. If so, its a bigger problem. If the problem is fixed, bring things back online one by oneb testing in between each step to find the culprit
I’ll have to do all this live because if it’s a server/permissions issue it won’t show on a local host.
ALthough uploads is set to 777
Ok, thanks for the help but still no.
Disable all plugins: still a 404 on the file.
Default theme: 404
Disable permalinks: 404
Clear .htaccess: blank page!
Restore .htacess back to the above three and still a 404.
Ok sorted! Here’s the deal:
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 WordPressSimply 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.
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!
Having this same issue – WP 3.0 on IIS7. Using these rules in web.config:
<rule name=”wordpress” patternSyntax=”Wildcard”>
<match url=”*” />
<conditions>
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
</conditions>
<action type=”Rewrite” url=”index.php” />
</rule></rules></rewrite>
Images up load fine, are in the directory they are supposed to be in – but only the /resized/ versions are accessable via URL – otherwise I get a 500 error! It’s nuts. I can download the media via FTP and it opens file locally…
I’ve spent about 6 hours trying to resolve this. Very frustrated.
I found the issue – and the fix to this unbelievably annoying problem. WordPress needs to mention this in the setup for Windows servers… I spent 4 days tearing my hair out over this simple permissions issue with PHP and wp-admin/uploads.
See:
https://www.howyoudo.info/index.php/how-to-fix-windows-server-upload-file-inherit-permissions-error/
- The topic ‘Strange File/404 issues’ is closed to new replies.