Support » Plugin: Simple 301 Redirects by BetterLinks » Undefined array key “HTTP_HOST”

  • Resolved makkabi

    (@makkabi)


    My debug.log is fulll of this warning:

    PHP Warning: Undefined array key “HTTP_HOST” in […]/wp-content/plugins/simple-301-redirects/wp-simple-301-redirects.php on line 171

    I’m using spinupwp on my server, which uses the wp-cli, and since HTTP_HOST isn’t available on non HTTP requests, I guess this causes this warning.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @makkabi,
    Good Day!

    Thank you for letting us know regarding the warning. Our dev team will work on this and hopefully, the issue will be resolved in our future update.

    Thank you for your patience.

    Thread Starter makkabi

    (@makkabi)

    Hi @aarin,

    two update later, this simple one line issue still hasn’t been fixed. For your developers or anyone still having this issue, this is the fixed line 170:

    return $this->get_protocol().'://'.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '' ).(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '');

    Yes, please apply the provided patch in future versions!

    Hey,
    we have this issue as well using php-cli to run wp-cron periodically.

    I solved it for us by adding this to line 112 (in function redirect() {})

    if (!isset($_SERVER['HTTP_HOST']) || (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == 'wp-cron.php')) {
    return;
    }

    I leave it to the developers to decide which fix is more generic. Please provide a fix. Thanks!

    • This reply was modified 6 months, 1 week ago by zitrusblau.
    • This reply was modified 6 months, 1 week ago by zitrusblau.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Undefined array key “HTTP_HOST”’ is closed to new replies.