WordPress.org

Ready to get started?Download WordPress

Forums

WP_HOME and WP_SITEURL (4 posts)

  1. merzedes
    Member
    Posted 4 years ago #

    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',    'http://example.com');
    define('WP_SITEURL', 'http://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')  =>  http://example.com
     get_bloginfo('stylesheet_url') => http://localhost/path/to/style.css

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

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

  2. MichaelH
    Member
    Posted 4 years ago #

    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 http://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 http://yourdomain.com/blog

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

  3. merzedes
    Member
    Posted 4 years ago #

    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 http://example.com vs. http://example.com/blog.

    Perhaps something to deprecate?

  4. MichaelH
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic