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_HOME and WP_SITEURL in wp-config override the URLs stored in the database

Config
~/tips/tip-wordpress-wp-home-siteurl-constants

define( 'WP_HOME', 'https://example.com' );

Forces the WordPress site address from wp-config.php without changing what the database stores.

Move a WordPress site to a new address with the wrong values in the database and you can lock yourself out of the login page. Two constants in wp-config.php are the quick way back in.

define( 'WP_HOME', 'https://example.com' );
define( 'WP_SITEURL', 'https://example.com' );

Put them above the line that says to stop editing. According to the documentation, WP_HOME overrides the home value in the wp_options table and WP_SITEURL does the same for siteurl, in both cases without changing the database. The settings fields in the admin then show the URLs but cannot be edited.

That makes it a good rescue move after a move or a typo in Settings, General. The site comes up on the address you wrote down, you log in, and you fix things properly.

Caveats: the database still holds the old values. If you remove the lines later, WordPress goes back to them, so the permanent fix is wp search-replace or correcting the options with wp option update home and wp option update siteurl. Also use the full address with https:// and without a trailing slash. A wrong value here gives redirect loops.

The two usually hold the same address, apart from sites that keep WordPress in a subfolder while the front page lives at the root.

Further reading: Editing wp-config.php, WP_HOME and WP_SITEURL (WordPress Advanced Administration)

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Config tips include extraconfig.txt root = true npm config list –smart-case jellyfin --cachedir /srv/jellyfin-cache All Config tips (9) All topics

Link