wp_options siteurl vs wp-config
-
Running WP 5.0.2 with mysql on Ubuntu 16.04.
I auto-deploy my personal WP installs and set the siteurl via the wp-config method:
define( 'WP_HOME', 'https://example.com' ); define( 'WP_SITEURL', 'https://example.com' );
Recently I noticed that while accessing the site via example.com, I was getting random errors. All image requests would redirect and lots of cross-site security errors. I have a second domain (say example2.com) that redirects to example.com…but the site should run under example.com only.
Originally when I setup the site I was going to use example2.com as the primary…but changed my mind and updated the provisioning scripts to use example.com instead.
so wp-config.php originally had WP_HOME/SITEURL set to example2.com and then was changed to example.com.
The database (SELECT * FROM wp_options WHERE option_name='siteurl';
) is set to use example2.com still and certain types of generated URLs (e.g. for image resources) are using the url from the database as the baseurl instead of the url from wp-config.php.So the site runs under example.com but a lot of resources are requested from example2.com…which redirects to example.com so you don’t notice at first…but lots of little problems quickly become apparent.
Is this a bug or do I just not understand the precedence of various settings.
The UI (Settings>General) have siteurl/home text fields greyed out and show the values from wp-config.php…but the database doesn’t reflect that.
Of course I can just add a little mysql to my provisioning to make sure that database field is getting updated…but seems like the values in wp-config should take precedence and/or cause the db config to be updated.
Same issue for home option.
SELECT * FROM wp_options WHERE option_name='home';
The page I need help with: [log in to see the link]
- The topic ‘wp_options siteurl vs wp-config’ is closed to new replies.