you've got htaccess probs

How To: Fix Your Missing WordPress Images

posted in: Designer 0

My images disappeared, and I got 404 Errors when trying to direct access their URLs.

  • Most of my images were suddenly missing in WordPress, but when I FTP’d into my “wp-content/uploads/” folders, they were all there.
  • Also–I couldn’t directly pull them up even when typing in their direct URL. That was the tipoff. I actually got the answer from this Drupal site.

3. Your .htaccess file is corrupt. #

The .htaccess file is very fussy, and only works if things are in a certain order. If you’ve tried to add password protection or to block image hotlinking (especially if you used cPanel or some other software to set that up), you’ve probably corrupted the file. The simple solution is to delete your corrupted .htaccess file, then upload the standard version that comes with Drupal.

So there you have it. I had recently been puttering around in my cPanel (usually a bad idea) because I came across a “Ten Easy Steps To Win The Internet” post about making my site load faster, and I decided to make sure image hotlinking only worked from domains hosted on my server. Well, apparently when you do that, Apache gets all huffy and screws up the .htaccess file.

Have you been messing around in your server’s settings lately?

How To Fix It:

In the folder that my WordPress installs in (subfolder /blog in this case), I got rid of the current .htaccess file (by renaming it to .htaccess.copy1) and added a new one, a text file I pasted the following script in:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

Important: Is Your WP installed in a Subfolder?

Remember, if you think you need redo your htaccess file, and you install your wordpress at your root folder (as many people do) instead of a /blog subfolder like me, do not put the “blog/” part in the “RewriteBase” & “RewriteRule” lines. Instead, copy this below, or go to this wordpress site and copy whatever they’re doing nowadays.

# 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

Again, if you installed your WP in a different location, here’s how that will have to work:

Like, if you’re WP blog is installed at:

http://helloworld.com/subfolder/subfolder2/ 

then you need to type as the 4th line above:

RewriteBase /subfolder/subfolder2/ 

 and as the 8th line above:

RewriteRule . /subfolder/subfolder2/index.php [L]

Here’s a step-by-step.

  1. Open a new text file (“Notepad” app, or whatever you like).
  2. Paste the most appropriate version of the htaccess script in it.
  3. Save the text file as “.htaccess
  4. Open an ftp window to your website, navigate to where your WordPress install folder is. (for me, with cPanel, it’s a folder named: “ftp://blahblah.com/public_html” and then a subfolder “/blog“)
  5. Find the current .htaccess file (it may be the culprit even if you don’t see anything wrong with it). Rename it to .htaccess.copy1, or something different.
  6. Copy and paste the .htaccess file you made earlier into the folder.
  7. Now reload your website, and see if your images are back. Mine were.

If this is all Greek to you, try calling your web hosting company for support, it’s probably the fastest way for you to get this fixed.

Leave a Reply about how this blog changed your life.