• I have difficulties to understand the idea behind WP_HOME and WP_SITEURL. By reading the documentation I thought that I could have something like

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

    where the public would read my blog via WP_HOME while the administration would be ‘non-public’, i.e. only accessable via ‘localhost’ in this case.

    Now, this does not work:

    get_bloginfo('url')  =>  https://example.com
     get_bloginfo('stylesheet_url') => https://localhost/path/to/style.css

    The URL returned for stylesheet_url is bit unexpected as I expected it to start with https://example.com.

    So, what’s the point of having WP_HOME and WP_SITEURL?

Viewing 3 replies - 1 through 3 (of 3 total)
  • It is somewhat redundant, but if you set those values in wp-config.php then a user can’t accidently change the Settings->General, WordPress and Blog address values.

    It’s also useful if you want to give WordPress its own directory where you access your blog at https://yourdomain.com, but the WordPress files are in a subfolder of your web-root, say a folder called blog, so that WP_SITEURL would be set to https://yourdomain.com/blog

    WP_SITEURL is your WordPress address (URL) and WP_HOME is your Blog Address (URL).

    Thread Starter merzedes

    (@merzedes)

    Hi Michael,

    if you set those values in wp-config.php then a user can’t accidently change the Settings->General, WordPress and Blog address values.

    Understood. This is, nevertheless, a side issue as I haven’t asked for the effect of setting this variables in wp-config.php. Another neat effect is that it overrides values burried in the database. This makes it then particular easy to move an installation from one domain to another.

    The point is that the documentation hides the fact that both URLs must be accessible for the dear reader. This took my by some surprise. I — and other users judging this forum — can’t really see a benefit of having this “nested” relationship https://example.com vs. https://example.com/blog.

    Perhaps something to deprecate?

    The point is that the documentation hides the fact

    Nice thing about the documentation is that it is a wiki and can be revised by any Codex registered user.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP_HOME and WP_SITEURL’ is closed to new replies.