Hi @nightdark,
I’m curious on why a php solution wouldn’t fit your needs.
That said, you can try the following:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [R=301]
Found here:
https://stackoverflow.com/questions/12237579/how-to-use-errordocument-404-with-301-in-header
Hope this helps.
Cheers
Actually, that .htaccess code will cause all posts that use permalinks to fail and go to the main blog page instead, because those permalinks don’t physically exist as files or directories.
So, WordPress actually needs to intercept requests that would normally generate a 404 first to see if they exist as a post with a certain permalink and then throw out a 404 response if it doesn’t exist.