I recently switched one of my sites over from Joomla to WordPress and, for the most part, everything went well but I did hit a little bit of a problem when all of a my posts suddenly started giving 404 errors.
UPDATE: This article isn’t wrong but it’s not exactly right either. The real solution can be found here.
Unfortunately I’d install a few plugins and messed around with some settings before I noticed the problem so I wasn’t entirely sure where to go looking. A googling turned up a load of pages where people reported the same issue but everyone indicated that the problem was with the .htaccess file and I was fairly sure mine was correct.
I remembered that I’d played with the Permalinks setting so I figured that would be the best place to start. I’d switched away from a Custom Structure to Day and Name as a test since they looked the same but I hadn’t noticed there’s actually subtle difference. The Custom Structure starts with /index.php/ whereas the Day and Name doesn’t as you can see here:
The problem is that the .htaccess rewrite rules that are generated for the two different settings are the same:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
The first rewrite rule basically says only perform the rewrite if the request starts index.php. That means the Day and Name setting will never produce a valid Permalink. The solution is easy, just use the Custom Structure and start it with /index.php/.