?
Solved

get domain and subdomain

Posted on 2008-11-06
6
Medium Priority
?
234 Views
Last Modified: 2013-12-13
hi experts

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

Thanks
0
Comment
Question by:cabou
  • 3
4 Comments
 
LVL 3

Expert Comment

by:sistemu
ID: 22893953
Hi,

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

It should do it.
0
 

Author Comment

by:cabou
ID: 22893977
this is not working.... it returns the full url
radio.domain.com/123765/12637 instead of only radio.domain.com
0
 
LVL 3

Expert Comment

by:sistemu
ID: 22894033
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.
0
 
LVL 3

Accepted Solution

by:
sistemu earned 2000 total points
ID: 22894051
$uri = explode("/", $_SERVER['HTTP_HOST']);
echo $uri[0];
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question