I know there are loads of posts here with a similar title but none have solved my issue. I've migrated a site from wordpress.com. All is fine except that permalinks are not working.
The apache rewrites are definitely working because the 404 comes from WP not the apache server (and if I remove the .htaccess file I get a 404 from apache). The contents of .htaccess have been written by WP.
I have permalinks set to 'day and name' in settings. The slug is being written to post_name in the wp_posts table. Links to posts provided by WP are being constructed properly. But WP can't find the post when I click the link. Looking at the mysql queries WP performs it does not even look for the slug in post_name (although it does look for it in wp_terms.slug and it's not there).
One of the queries looks a bit odd to me although this might be a read herring:
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND 0 = 1 AND wp_posts.post_type = 'post' AND ...
Clearly 'where 0 = 1' is never going to return anything.
Any help much appreciated.