Link to home
Start Free TrialLog in
Avatar of cabou
cabou

asked on

get domain and subdomain

hi experts

I would like to know what domain is my users using.
for exemple:
radio.domain.com
www.domain.com
domain.com

Thanks
Avatar of sistemu
sistemu
Flag of Romania image

Hi,

Try $_SERVER['SERVER_NAME'] or  $_SERVER['HTTP_HOST'].

It should do it.
Avatar of cabou
cabou

ASKER

this is not working.... it returns the full url
radio.domain.com/123765/12637 instead of only radio.domain.com
You tried $_SERVER['HTTP_HOST'] too?
I used it many times and never let me down.
But if you still get the long version, you should use an explode with "/" and save only the first element.
ASKER CERTIFIED SOLUTION
Avatar of sistemu
sistemu
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial