What's the best way to identify subdomains by PHP dynamically?

Posted by kavoir.com on Stack Overflow See other posts from Stack Overflow or by kavoir.com
Published on 2010-04-11T12:41:12Z Indexed on 2010/04/11 12:43 UTC
Read the original article Hit count: 240

Filed under:
|
|

I have configured the wildcard DNS of *.mydomain.com and it's all working properly. My question is which of these should I rely on identifying client subdomain requests?

  1. $_SERVER["HTTP_HOST"]
  2. $_SERVER["SERVER_NAME"]
  3. $_SERVER["SCRIPT_URI"]

They all seem to contain the subdomain part I want but after reading this article by Chris: http://shiflett.org/blog/2005/feb/more-on-filtering-input-and-escaping-output, I'm lost at see and there appears to be no safe way to do this?

Any idea on accomplishing this task securely?

© Stack Overflow or respective owner

Related posts about php

Related posts about subdomain