Connecting Tech Pros Worldwide Help | Site Map

Detecting and displaying the domain name

  #1  
Old July 17th, 2005, 02:24 AM
Charles
Guest
 
Posts: n/a
Hi,

I have a site that has several domains pointing to its DNS.
I would like to implement a script that will grab the domain name visitors typed in, and display it
on the page. Is there a way to do it?
Thanks,

--
Charles.


  #2  
Old July 17th, 2005, 02:24 AM
Janwillem Borleffs
Guest
 
Posts: n/a

re: Detecting and displaying the domain name



"Charles" <nothing@nothing.com> schreef in bericht
news:bqa597$1v0kt0$1@ID-208473.news.uni-berlin.de...[color=blue]
> Hi,
>
> I have a site that has several domains pointing to its DNS.
> I would like to implement a script that will grab the domain name visitors[/color]
typed in, and display it[color=blue]
> on the page. Is there a way to do it?
> Thanks,
>[/color]

$_SERVER['HTTP_HOST'] (use phpinfo() to lookup vars like this)


JW



  #3  
Old July 17th, 2005, 02:24 AM
Charles
Guest
 
Posts: n/a

re: Detecting and displaying the domain name


Thanks, it's working fine. Is there a way to display only the name with www and extention such as:

- name

instead of

- www.name.com

Thanks again,

--
Charles.


  #4  
Old July 17th, 2005, 02:24 AM
Janwillem Borleffs
Guest
 
Posts: n/a

re: Detecting and displaying the domain name



"Charles" <nothing@nothing.com> schreef in bericht
news:bqa6e5$1vj1fr$1@ID-208473.news.uni-berlin.de...[color=blue]
> Thanks, it's working fine. Is there a way to display only the name with[/color]
www and extention such as:[color=blue]
>
> - name
>[/color]

Shure, per example with:

$name = ereg_replace(
"^(www.)?([^.]+).[^.]+$", "\\2",
$_SERVER['HTTP_HOST']
);


JW



  #5  
Old July 17th, 2005, 02:24 AM
Charles
Guest
 
Posts: n/a

re: Detecting and displaying the domain name


Wow thank you very much Janwillem, you're very helpful.
Have a nice week-end,

--
Charles.


Closed Thread