[PHP] $_SERVER['HTTP_HOST'] without the 'www.'
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SERVER['HTTP_HOST'] without the 'www.'
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.'. This should be Apache's job - you can configure the webserver to redirect requests from example.com to www.example.com without PHP's involvement, if that's what you're interested in. 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? preg_match() should get you started. /(\w+\.\w+)$/ ought to match just the primary domain. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SERVER['HTTP_HOST'] without the 'www.'
* and then Shaun declared 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.'. parse_url() ;-) -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SERVER['HTTP_HOST'] without the 'www.'
On Tue, 2004-08-31 at 09:38, Shaun wrote: 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? str_replace() You can replace the www. with an empty string. -- Greg Donald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php