Re: $_SERVER['HTTP_HOST'] without the 'www.'
| From: | Torsten Roehr | Date: | Tue, 31 Aug 2004 15:49:57 +0000 |
| Subject: | Re: $_SERVER['HTTP_HOST'] without the 'www.' | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195297@lists.php.net to get a copy of this message | ||
"Shaun" <shaunthornburgh@hotmail.com> wrote in message
news:20040831143844.62569.qmail@pb1.pair.com...
> Hi,
>
> How can I get the URL of the page I am on without the 'www.' i.e. just
> mydomain.com? I need to enurse this is correct in case the user types in
the
> domain without using the 'www.'.
>
> I have looked at using substr but if the user leaves out the 'www.' then
> substr($_SERVER['HTTP_HOST'], 4) would return 'main.com', is there a
better
> function to use in this instance?
>
> Thanks for your help
Does your Apache provide $_SERVER['SERVER_NAME']? For me it outputs the
domain like "google.com".
Regards, Torsten Roehr