12月 04, 2011

IIS Fast-CGI HTTPS

$_SERVER['HTTPS']
Set to a non-empty value if the script was queried through the HTTPS protocol.
Note:Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.
上面這段文字來源是官方說明文件。而本篇文章的重點是
當PHP在IIS透過FastCGI執行的時候,$_SERVER['HTTPS']的值也是off,而不是empty value

所以因此產生了一個問題:isset($_SERVER['HTTPS'])
在這種環境下,測試isset()是沒有意義的,只會回傳TRUE
應該改為類似這種判斷式
if($_SERVER['HTTPS'] == 'off')

註:Gallery 1就有上述的問題。詳細說明點此

沒有留言:

張貼留言

歡迎留言~登入身分再留言方便後續意見交流喔!
當然,沒登入也可以留言!