Request META Help

Chris Angelico rosuav at gmail.com
Thu Apr 19 11:36:55 EDT 2012


On Thu, Apr 19, 2012 at 11:32 PM, Gabriel Novaes <semproblema at gmail.com> wrote:
> The domains testes1.xyz.com.br, tes.xyzk.com.br, xx.xyzk.com.br through a DNS redirect TYPE A link to the server IP.
>
> In most cases I get the request.META ['HTTP_HOST'] with the URL in the request header, but today I had a problem that a customer made an appointment for me, and I get the IP of the server that information. Actually I need to get tes.xyzk.com.br
>
> Does anyone know better how it works? How can I overcome this?

As I understand it, your customer accessed your web site via direct IP
address. The easiest way to deal with that is to have a single default
name, and if the Host: header (which is what comes through as
HTTP_HOST) doesn't match any of the names you're expecting, you treat
it as though it had been sent as your default. This is how Apache
works when using name-based virtual hosting, and you seem to be doing
pretty much the same thing, so following convention will keep things
convenient.

ChrisA



More information about the Python-list mailing list