WordPress theme images not displaying? Could be .htaccess file.

A short while back I moved my entire website from a Windows server to an Apache server. I had to do it because I found out the hard way that PHP and the Yii framework don’t really enjoy running on a Windows server. I removed the web.config file used for a Windows server from my WordPress installation and put in the standard .htaccess file. I tested my blog and everything seemed to work fine except for one thing. All of my theme’s images had disappeared. I checked Firefox’s web developer console and an error of “404 Forbidden” showed up. I immediately assumed it had to do with file permissions with my WordPress files on the server. The folders for my WordPress theme had all of the right permissions, so it had to be something else. Doing some more research, I came to the conclusion it was my .htaccess file. My WordPress installation was in a sub-directory and my .htaccess file didn’t reflect that fact. This is what I changed my .htaccess file to:

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

I made the change and all of my theme images instantly came back. My WordPress installation is in a sub-directory named ‘blog’. If your sub-directory is named something different, you must change the two lines where the name of the sub-directory is referenced. First on the line where it starts with “RewriteBase…” and on the line where it starts with “RewriteRule…”. Remove the word ‘blog’ and insert the name of your sub-directory. If you find your WordPress theme images are not displaying, check your .htaccess file along with your file permissions.

Matthew Dailey

Web developer, photographer, and Photoshop user.