brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp rewrite flush --hard fixes wordpress 404 errors after a permalink change

WordPress
~/tips/tip-wordpress-rewrite-flush-hard-permalinks

wp rewrite flush --hard

Rebuilds the permalink rules, and the .htaccess file with --hard, to cure 404 errors on posts.

New post types or a moved site often give 404 pages until the permalinks are saved again.

wp rewrite flush --hard
wp rewrite list --format=table

wp rewrite flush rebuilds the rewrite rules stored in the database, the same as pressing Save on the Permalinks screen. With --hard it also updates the .htaccess file, but only on a single site install, and WP-CLI only does that when mod_rewrite is listed under apache_modules in wp-cli.yml. On nginx the web server configuration decides, so the usual fix there is a correct try_files line. wp rewrite list prints the rules, handy to see whether a custom post type is registered at all.

Further reading: WP-CLI: wp rewrite flush

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link