[UPHPU] server name, http_host & same origin policy

Alvaro Carrasco alvaro at epliant.com
Sun Mar 4 20:06:47 MST 2007


Walt Haas wrote:
> Cool.  How do you know the request went to http://sample.com?  Or do you
> put the redirect in the Apache config?
>   
i usually do something like:
if (strpos($_SERVER['HTTP_HOST'], 'www') !== 0)) {
  header("Location: http://www.sample.com");
  die();
}

> Looking at $_SERVER, the only thing that tells me who the browser thinks
> it's talking to is $_SERVER['HTTP_HOST'], which I believe contains
> whatever the browser said to put there, if anything.  Firefox 1.5 and IE
> 6 get it right.  
I haven't had any problems relying on HTTP_HOST.
If you use name-based VirtualHosts on apache, you are already depending 
on that header.
> If I point Links at http://thewebsitedoctor.net,
> HTTP_HOST contains www.thewebsitedoctor.net.  I don't know where that
> change gets made.  
>
>   
That's strange, i haven't seen that before.

Alvaro




More information about the UPHPU mailing list