Post name permalink doesn’t work

I changed the permalink structure of my site from default to postname, but this does not work: trying to access a post returns me the error 404.

Then I tried to try other types of permalinks, and everyone worked (except /%postname%/, of course). So I tried to create a custom permalink: /index.php/%postname%/. This works and I can not understand why.

I tried to change the theme and to set the structure postname and everything works perfectly. From what can be due to the error?

This is my .htaccess file:

BEGIN WordPress

RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

END WordPress

I also have Module rewrite already enabled and

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted

Still doesn’t work, any ideea?