Cannot Flush Permalinks with WP-CLI

I solved the problem by adding wp rewrite flush --hard command and setting mod rewirte in the global wp-cli configuration file:

wp rewrite structure '/%postname%/'
wp rewrite flush --hard

config.yml

apache_modules:
  - mod_rewrite

In this way, the .htaccess file gets regenerated. According to the official docs, this is needed in order to flush the permalinks.

I also wrote a detailed guide on how to update the permalinks on Apache web server with wp-cli: How to Update WordPress Permalinks with WP-CLI on LAMP Server

tech