WordPress permalink nextpage doesn’t work

I’ve been struggling with an aspect of WordPress that should ‘just work’ but didn’t. That is, if you have decided to restrict the number of pages/posts shown on a page, WordPress automatically generates a ‘next page’ and ‘previous page’ button.

This works fine if you have the standard ‘ugly permalinks’ set up, but if you use custom permalinks it breaks.

The problem is with the .htaccess code that WordPress generates – at least if you’re using it on a server that runs PHP as a CGI. To fix it, I simply edited the .htaccess and instead of the RewriteRule looking thus;

RewriteRule . /index.php [L]

Make it

RewriteRule (.*) /index.php/$1 [L]

This has the effect of passing the PATH_INFO data through to index.php which was stripped by the previous rule. Now WordPress will find your pages properly again and all will work 🙂

This fixes the problem of permalink nextpage giving a 404 error page. The existing WordPress articles probably will work for you if you’re just seeing the ‘no posts’ error.