Hacker News new | ask | show | jobs
by Domenic_S 4045 days ago
Certainly there are configuration options that are appropriate to store in the database, but I'm trying to understand why domain is one of them. The site knows what domain it is on by virtue of being hosted on that domain.

Storing the domain in the DB may be reasonable if it's done once, but WP does it multiple times: WP_SITEURL ("the address where your WordPress core files reside"), WP_HOME ("the address you want people to type in their browser to reach your WordPress blog") and of course GUIDs for every post have the domain hardcoded into their values (that can mess up links in a weird way, where you're on your local environment, click a link, and now you're silently on prod).

I could definitely be missing something, but I can't for the life of me figure out why this is a good idea.

2 comments

There are only two places where the URL should be stored. Anywhere else is an issue with the plugin or theme storing them incorrectly. Both are contained within the wp_options table for home URL and site URL. Those are the only values required to be changed. If you have a development environment, you should not be migrating the wp-config.php file anyway as it has sensitive information for product sites thus on your dev site you can have a separate wp-config.php file to take into account the new values for home and site URL's.
You aren't missing anything. This problem has been there in WP for a long time, and it makes staging/testing/migration setups a horrible pain (as others have suggested, lots of search & replace).
It's two constants in your dev environment wp-config.php, nothing more.