There are so many ways to enter a URL that I just created an array and tried them all ...
This happens to be for domains only:
private function pageFoundGet( $domain )
{
$types = array(
"file_get - 1"=>$domain,
"file_get - 2"=>'www.' . $domain,
"file_get - 3"=>'http://www.' . $domain,
"file_get - 4"=>'https://www.' . $domain,
"file_get - 5"=>'http://' . $domain,
"file_get - 6"=>'https://' . $domain
);
foreach ($types as $code => $value) {
if ($this->domain_file = $this->fileGetContents( $value ))
{
$this->file_start_code = $code;
return true;
}
}
return false;
}
But what is the correct way ?
You have to provide the protocol and the domain. So in your case, you shouldn't use 1 and 2.
Now it's important, that each of the variants 3-6 could show completly different content and each of them is correct. You could show two different pages for http and https and you could even show different content for www and non www urls.
Usually, there's a redirect, which redirects every of these requests to the same location, but that is not neccessary. file_get_contents
is smart enough to follow this redirects on his own, so you even don't need to know, that an redirect exists.
What I usually do is: Just put the url in the browser and use that for file_get_contents.