473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How can I access a case sensitive host name?

Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For
example if I type HostName.domain.com in my browser I want to return it
exactly as it appears in the location part of the browser
"HostName.domain.com" but it keeps returning a case insensitive result
"hostname.domain.com".
Jul 17 '05 #1
9 3320
Jeff wrote:
Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For
example if I type HostName.domain.com in my browser I want to return it
exactly as it appears in the location part of the browser
"HostName.domain.com" but it keeps returning a case insensitive result
"hostname.domain.com".


I would imagine the hostname that's being passwed to $HTTP_HOST (and
incidentally you should really be using $_SERVER['HTTP_HOST']) is what's
defined in the web server's configuration, which is likely to be in lower
case.

It's possible that even if it were allowed to be in mixed case in the web
server's config that it might still be passed to PHP as lowercase, or that
the browser itself is lowercasing the domain when it makes the request to
the server.

Regardless of all this, there's no way you can assume that an end-user will
actually type the domain into their browser using mixed case so you cannot
rely on this in your script.

At least now your other question about adding spaces before upper cased
letters now has some context :)

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2
In article <dXC9d.205753$MQ5.116054@attbi_s52>, Jeff wrote:
Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For
example if I type HostName.domain.com in my browser I want to return it
exactly as it appears in the location part of the browser
"HostName.domain.com" but it keeps returning a case insensitive result
"hostname.domain.com".


Since when are hostnames case sensitive then?
Are you even sure your browser requests Foo instead of foo?

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #3
On Fri, 08 Oct 2004 20:40:41 GMT, "Jeff" <jm**@mail.com> wrote:
Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For
example if I type HostName.domain.com in my browser I want to return it
exactly as it appears in the location part of the browser
"HostName.domain.com" but it keeps returning a case insensitive result
"hostname.domain.com".


This behaviour makes sense - what's your need for case-sensitivity in the
case-insensitive domain name system?

RFC1035 sec 2.3.1 <http://www.ietf.org/rfc/rfc1035.txt>

"Note that while upper and lower case letters are allowed in domain
names, no significance is attached to the case. That is, two names with
the same spelling but different case are to be treated as if identical."

Monitoring HTTP requests with Ethereal made through Firefox and Internet
Explorer 6 shows that it converts the host to lowercase before it makes the
request - no mixed case Host: header gets through to the server.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #4
Thanks guys, I now understand the potential problems with this approach.
I have decided using underscores to separate multiple words in the host
name will prevent these problems while still enabling me to detect and
decipher multi worded host names.
Jul 17 '05 #5
Jeff wrote:
Thanks guys, I now understand the potential problems with this approach.
I have decided using underscores to separate multiple words in the host
name will prevent these problems while still enabling me to detect and
decipher multi worded host names.


You'll be better to use dashes - and not underscores _ in your hostnames. I
have seen underscores used in hostnames before, but you're only allowed
a-z, 0-9 and - in domain names so it's best to stick to this for hostnames
as well.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #6
> For example if I type HostName.domain.com in my browser I want
to return it exactly as it appears in the location part of the
browser [snip]


I would venture to guess this isn't possible. What the user types in
their address/location is a client request. His or her client takes this
request and (via DNS) translates that to an address. If an appropriate
program is listening at that address, it will process the request and
send a response.

I don't see anything on this path where the actual string typed by the
user is ever going to be transmitted all the way to the web server and
made available to server side programs.

Since this string is client side, it might be possible to get to it
through other client-side means (javascript, for example).

--cd
Jul 17 '05 #7
> Thanks guys, I now understand the potential problems with this
approach.
I have decided using underscores to separate multiple words in the host name will prevent these problems while still enabling me to detect and
decipher multi worded host names.


You've got me curious: what are you doing? I don't mean that negatively:
I'm really curious what you're up to here, if you don't mind sharing.

--cd
Jul 17 '05 #8
Sounds good, thanks.
Jul 17 '05 #9
>I would venture to guess this isn't possible. What the user types in
their address/location is a client request. His or her client takes this
request and (via DNS) translates that to an address. If an appropriate
program is listening at that address, it will process the request and
send a response.
Modern web servers that serve multiple web sites depend on the HTTP
Host: header to determine what virtual host the request is for.
The days of needing a separate IP address for each virtual host
were long over 5 years ago.

A typical setup will have DNS entries for www.mysite.com and
www.yoursite.com and maybe a few hundred other names CNAMEd (or,
it could use A records) to www.ispwebserver.com. Apache (or other
server software) looks at the Host: header to figure out which site
("virtualhost") the request is for, and serves up the appropriate
pages. You CANNOT tell this by the IP address (the same for all 3
names above).
I don't see anything on this path where the actual string typed by the
user is ever going to be transmitted all the way to the web server and
made available to server side programs.


The host name as the user types it should appear in the Host:
header. However, no guarantees that the case won't be changed
before it gets to the server, and definitely no guarantees that
the server won't just give the virtual host name as it appears
in the config file.

Gordon L. Burditt
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul Smith | last post by:
This doesn't seem like it should be *that* difficult, but after quite some time trying to figure it out, I'm still banging my head against the wall. My objective is to examine the exact...
2
by: Matthew Louden | last post by:
I am using VBScript for ASP. The control value must be case sensitive? The following example should print the "fname" value, but if if I change "submit" back to "SUBMIT". Then it works fine. <%...
14
by: MLH | last post by:
I have a friend with a database application on a web server. He has invited me to attach to it so I can extract data from it periodically. I have a few questions... 1) I have a DSL connection to...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
1
by: Boban Dragojlovic | last post by:
Say I have a dropdownlist control of the US State Codes <asp:dropdownlist id=ddlStateCode ...> <asp:listitem value="AL">Alabama</asp:listitem> <asp:listitem value="CA">California</asp:listitem>...
1
by: thermate | last post by:
http://www.latimes.com/news/nationworld/nation/la-na-libby26jan26,1,2730931.story?coll=la-headlines-nation Aide testifies Cheney helped effort to discredit Wilson By Richard B. Schmitt, Times...
38
by: Bart | last post by:
Why is C case sensitive? I know it's a bit late to change it now but there would seem to be far more advantages in ignoring letter case in source code. In real life such a situation would be...
10
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Not sure if I quite follow that. 1....
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.