Regenerate permalinks and rewrite rules
wordpress posts return 404 | save permalinks from command line | pages not found after migration | wp-cli | permalinks | seo | 404Caution: This command changes the system. Understand what it does before you run it.
wp rewrite flush --path=/var/www/vhosts/example.com/httpdocsDiscards the stored rewrite rules and rebuilds them, just like saving the permalink settings in the dashboard. Helps with 404 errors after migrations, plugin changes or new post types. Critical for SEO, since 404s on existing URLs cost rankings.
Note: .htaccess is only written with --hard, and even then only if WP-CLI detects mod_rewrite (via apache_modules in wp-cli.yml). Under nginx, check the rules in the server configuration.
Also searched as
- wordpress posts return 404
- save permalinks from command line
- pages not found after migration