Page 1 of 1

[SOLVED] how to tell if user has went to root site?

Posted: Thu Jan 27, 2011 1:45 am
by stevestark5000
i got a cms that i am working on. i need to tell is a user has went to the root of a website, where a website can be any website. if example.com will not be good enought as i need to tell if the script is at any site. the code need to be in an if statement. for example. if (site at root) { }

Re: how to tell if user has went to root site?

Posted: Thu Jan 27, 2011 2:40 am
by Christopher
Use phpinfo() to look at the $_SERVER superglobal array. There are many values there that will be useful to you.

Re: how to tell if user has went to root site?

Posted: Thu Jan 27, 2011 2:55 am
by stevestark5000
can i have an example please?

Re: how to tell if user has went to root site?

Posted: Thu Jan 27, 2011 12:53 pm
by Christopher

Re: how to tell if user has went to root site?

Posted: Thu Jan 27, 2011 1:04 pm
by John Cartwright
Another way to look at what the $_SERVER superglobal has available would be to

Code: Select all

echo '<pre>'. print_r($_SERVER, true) .'</pre>';
which essentially gives you the same info as phpinfo() would.

Re: how to tell if user has went to root site?

Posted: Thu Jan 27, 2011 7:24 pm
by stevestark5000
solved. thank you.