Undefined index error using $_SERVER['HTTPS']

前端 未结 2 1182
挽巷
挽巷 2020-12-10 02:53

Debug is throwing...

Notice: Undefined index: HTTPS in C:\\xampplite\\htdocs\\testsite\\wp-content\\themes\\mytheme\\header.php on line 4

2条回答
  •  北海茫月
    2020-12-10 03:01

    Some servers simply don't set $_SERVER['HTTPS'] if the request is non-secure. Some others may set it to 'off'. You'll have to check it like this:

    if ( isset( $_SERVER["HTTPS"] ) && strtolower( $_SERVER["HTTPS"] ) == "on" ) {
        $pageURL .= "s";
    }
    

提交回复
热议问题