Site icon Denis Bouquet

Fix 404 errors for images in subdirectories on GoDaddy/Shared Hosting

One of those “it should just work” problems that I thought was linked to WordPress permalinks. I wanted to host a simple /static/ folder on my WordPress hosting to keep some assets separate from the media library. Seems simple, right? Create the folder, drop in the images, and call it a day. Every time I tried to load an image, WordPress intercepted the request with a 404 Not Found page.

I first looked into WordPress .htaccess to resolve the 404

By default, WordPress’s .htaccess file tells the server: “If a URL doesn’t look like a real file, give it to me to handle.” Since my /static/ folder wasn’t part of the WordPress database, WordPress assumed it was a broken link.

I went into my .htaccess file (I didn’t find it in the root directory via GoDaddy’s File Manager – invisible, I assume, but I created mine overriding the default one) and added a bypass rule right inside the # BEGIN WordPress block:

Apache

RewriteCond %{REQUEST_URI} !^/static/.*

This essentially tells the server: “If the URL starts with /static/, leave it alone. Don’t let WordPress touch it.”

Some image displaying mystery

After the code change no luck, I checked the folder. The weird thing was only three images were showing up from the beginning. The rest? Still 404s.

I double-checked my paths. I checked the spelling. I checked for case sensitivity (Linux servers hate Image.jpg vs image.jpg). Everything looked perfect. Why some loaded and others acting like they didn’t exist?

The solution, it wasn’t the code, it was the file permissions

Then I tried something else. When I uploaded the files, some of them (for whatever reason) inherited restrictive permissions. On GoDaddy and many other shared hosts, if a folder or file is set to something like 600 or 700, the web server is literally “forbidden” from seeing it. To the browser, “Forbidden” often looks like a “404 Not Found” because the server isn’t even allowed to acknowledge the file is there.

My static folder was on 775, I set it to 755 with “Apply to Enclosed”.

Steps:

  1. I went into the FTP folder (you could use your hosting panel File Manager).
  2. I right-clicked the /static/ folder and selected Permissions (or Chmod).
  3. I set the folder to 755.
  4. Crucially, I made sure to apply these permissions recursively to all subfolders and files.

As soon as the permissions were updated as 755, every single image popped up instantly.

Conclusion

If you’re fighting with a custom folder in WordPress and your code looks right, stop looking at your syntax and start looking at your permissions.

Hope this saves someone some headache. Happy WordPress days

Exit mobile version