Forum Moderators: phranque
www.domain.com
subdomain1.domain.com
subdomain2.domain.com
etc.
and am using PHP to determine whether the URL is www.domain.com or one of the subdomains:
if ($_SERVER["http_host"] == "domain.com") ¦¦ $_SERVER["http_host"] == "www.domain.com")
{
// URL is www
}
else
{
// assume URL is a subdomain
}
The above code works fine for the vast majority of my clients. My problem is that I have some clients that I know are HTTP/1.0 and this code is failing for them. When they go to www.domain.com, the php code executes the else code instead of the "www" code.
I searched the forums and found this comment:
"You may have had problems because some clients were using HTTP/1.0, which does not provide the Hostname request header tested by http_host"
So two questions I have:
1. Do HTTP/1.0 clients send an HTTP_HOST?
2. If they don't, is there a way I can get the URL they are requesting using PHP?
Many thanks in advance.
1. Do HTTP/1.0 clients send an HTTP_HOST?
2. If they don't, is there a way I can get the URL they are requesting using PHP?
1. No.
2. No, the information doesn't exist in HTTP/1.0.
This was a major reason for HTTP/1.1.
HTTP/1.0 does not allow for the use of shared IP addresses among several domains.
HTTP/1.1 added the Hostname header to HTTP requests to support shared virtual hosting.
You can detect HTTP/1.0 and redirect those visitors to a special page where they can select the desired "domain" by referring (linking) directly to the correct subdirectory. Do not do this redirect if the visitor is already requesting a subdorectory, otherwise, he/she'll be stuck in a loop.
Also do not allow search engine spiders to index this special page, or massive duplicate-content problems will ensue.
And... In order to prevent problems, I suggest you detect HTTP/1.0 by detecting the blank hostname; Some search engine spiders claim to be HTTP/1.0 clients, but can actually handle HTTP/1.1. If they supply a hostname, treat then as HTTP/1.1-capable.
Jim
I checked my logs and they show that googlebot is using HTTP/1.0. Does this mean that any site with:
www.domain.com
subdomain.domain.com
will have both the above URLs indexed in google as the same page? I would guess this would not be the case as this would cause horrible indexing problems with any site using subdomains. So the next question is, does googlebot send an HTTP_HOST header?
And... In order to prevent problems, I suggest you detect HTTP/1.0 by detecting the blank hostname; Some search engine spiders claim to be HTTP/1.0 clients, but can actually handle HTTP/1.1. If they supply a hostname, treat then as HTTP/1.1-capable.
Google is one of these that advertises HTTP/1.0 but is actually HTTP/1.1 capable. You can prove this with a bit of research in Google search results.
Jim