Forum Moderators: coopster

Message Too Old, No Replies

Determining if their using a subdomain or not?

         

benj0323

3:37 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



How would I find out if my script was being used as a subdomain or not?

Ex:

subdomain.domain.com

domain.com/subdomain

It needs to be dynamic to work with any subdomain.

Thanks.

ChadSEO

5:50 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



benj0323,

$_SERVER['HTTP_HOST'] should give you the full domain that was requested, so "www.example.com" or "sub1.example.com". $_SERVER['SERVER_NAME'] should give you the same value. Since there are two separate variables, I suppose it is possible they would be different, although I don't know any examples of when that would be the case.

[php.net...] will give you a list of predefined variables, in case you want to pull other URL information.

Chad

[edited by: coopster at 10:38 pm (utc) on Aug. 29, 2005]
[edit reason] fixed link [/edit]