I was going round in circles trying to get WordPress permalinks to work on a Ubuntu server with Apache2 installed.
The .htaccess file was fine:
# BEGIN WordPress
#
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
## END WordPress
However I still got Error 404 page not found when I went to siteurl.com/page-name rather than siteurl.com/?p=123
In the end it turns out I needed to make a tweak to the Apache virtualhost.conf file for the site in question:
By default in the
AllowOverride None
This needed to be changed to
AllowOverride All
A quick
service apache2 reload
And, hey presto, permalinks were working again.