• Resolved Peter

    (@oncoursegoggles)


    We are using a “WPSSO Core Standard” plugin for structured data and it returns a warning that the WP_HOME Constant Contains A Variable in our wp-config.php file.

    The WP_HOME constant definition in your wp-config.php file contains a variable. WordPress uses the WP_HOME constant to provide a single unique canonical URL for each webpage and Media Library content. A changing WP_HOME value will create different canonical URLs in your webpages, leading to duplicate content penalties from Google, incorrect social share counts, possible broken media links, mixed content issues, and SSL certificate errors Please update your wp-config.php file and provide a fixed, non-variable value for the WP_HOME constant.

    Here is the relevant code from wp-config.php

    * The WP_SITEURL and WP_HOME options are configured to access from any hostname or IP address.
     * If you want to access only from an specific domain, you can modify them. For example:
     *  define('WP_HOME','https://example.com');
     *  define('WP_SITEURL','https://example.com');
     *
    */
    if ( defined( 'WP_CLI' ) ) {
        $_SERVER['HTTP_HOST'] = 'localhost';
    }
    define('WP_SITEURL','https://' . $_SERVER['HTTP_HOST'] . '/');
    define('WP_HOME','https://' . $_SERVER['HTTP_HOST'] . '/');
    /** Absolute path to the WordPress directory. */
    if ( ! defined( 'ABSPATH' ) ) {
    	define( 'ABSPATH', dirname( __FILE__ ) . '/' );
    }

    How can we address this ?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • You need to change $_SERVER['HTTP_HOST'] to the actual URL you want to use, rather than using this global variable.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    It’s the plugin that’s complaining (correctly) about a legit use of a variable in wp-config.php. If you need that to be a variable and want to continue with that p;lugin, I recommend asking at https://wordpress.org/support/plugin/wpsso/#new-post so the plugin’s developers and support community can help you with this.

    Thread Starter Peter

    (@oncoursegoggles)

    Hello @sterndata

    Thanks for that; I have no idea if it’s a legitimate use of a variable. That is why I have posted here.

    You’re stating that the use of the variable is customary and correct?

    You also state that the plugin is correct to complain about the variable’s use, so I seek clarity.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    The message that the plugin has given you explains the issue. It looks like you’re site was migrated from a localhost environment. Do you use it from more that one server (e.g., locally and from a host) or is it only one some external host? See the comments at the top of the block you posted above, too.

    Thread Starter Peter

    (@oncoursegoggles)

    It’s only an external host.

    The site was moved from a shared hosting account to an AWS Lightsail Instance with Bitnami about a year ago; it should have never been a localhost, unless that was something that the former hosting company used in the shared hosting environment.

    I followed your suggestion and posted in the plugin forum as well.

    Thanks

    • This reply was modified 4 years, 6 months ago by Peter.
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    The site is working, so you can

    a) leave it alone and decide to ignore the warning, OR
    b) remove the variable content from wp-config.php, delting

    if ( defined( 'WP_CLI' ) ) {
        $_SERVER['HTTP_HOST'] = 'localhost';
    }
    define('WP_SITEURL','https://' . $_SERVER['HTTP_HOST'] . '/');
    define('WP_HOME','https://' . $_SERVER['HTTP_HOST'] . '/');
    /** Absolute path to the WordPress directory. */

    OR
    c) leave it alone and remove the wpsso plugin so you don’t get warned.

    six of one… 🙂

    Thread Starter Peter

    (@oncoursegoggles)

    We chose “b)” and all seems well.

    Thank you.

    • This reply was modified 4 years, 6 months ago by Peter.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Warning: WP_HOME Constant Contains A Variable’ is closed to new replies.