[UPHPU] server name, http_host & same origin policy
Alvaro Carrasco
alvaro at epliant.com
Sun Mar 4 19:04:05 MST 2007
Walt Haas wrote:
> Problem: My web site is at http://thewebsitedoctor.net or you may refer
> to it as http://www.thewebsitedoctor.net . Either way,
> $_SERVER['SERVER_NAME'] contains 'www.thewebsitedoctor.net'. That's not
> a problem until I construct a base URL from the value of SERVER_NAME
> then try to use that to load an XML file from the site. If the user
> happened to load the page as 'www.thewebsitedoctor.net' everything is
> fine, but if they typed just 'thewebsitedoctor.net' the browser looks at
> where the XML is coming from and say "Not the same origin, you lose".
>
> Any bright ideas out there? Don't put <base> in the <head>?
>
> TIA
>
>
I usually redirect any requests to
http://sample.com
to
http://www.sample.com
You can also try using $_SERVER['HTTP_HOST']
Alvaro
More information about the UPHPU
mailing list