ウェブサイトがSSLを使用しているかどうかを確認するスクリプトを作成しています。たとえば、「http://www.google.com/」を使用すると、「https://www.google.com/」にリダイレクトされます。それをどうやって確認できますか?私は次のcURLコードを使ってウェブサイトのヘッダーを取得しています。ウェブサイトがCURLを使用してSSLを使用しているか確認してください
は<?php
$url = 'https://www.google.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // set url
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); // set browser/user agent
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header'); // get header
curl_exec($ch);
function read_header($ch, $string) {
print "Received header: $string";
return strlen($string);
}
?>
出力:要件を満たすためには
HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Location: https://www.google.co.in/?gfe_rd=cr&ei=YEAkV7SEFrTv8wexyy0
Content-Length: 259
Date: Sat, 30 Apr 2016 05:19:28 GMT
Alternate-Protocol: 443:quic
Alt-Svc: quic=":443"; ma=2592000; v="33,32,31,30,29,28,27,26,25"
どのサイトでもhttps ....の返品を確認するだけです。 –
を試しました。その何も返さない –
@ダゴン私はコードを変更しました。これで、httpとhttpsの両方のWebサイトにアクセスできます。しかし、ヘッダーの違いはありません –