Page 1 of 1

current URL?

Posted: Sun May 23, 2004 3:32 pm
by rockindie
is there any PHP code i could use to find out what is the exact url that the user has reached the site by.
like return respectively "http://mysite.com/blah.php". i hope i have explained myself well. thanks in advance.

(i'd like to use this to have 2 domains parked on one webhost, like site1.com and site2.com have the same webhost/files but the code would figure out if youve visited the site by going to site1.com or site2.com so it would display the correct site)

Posted: Sun May 23, 2004 3:34 pm
by Steveo31
$_SERVER['HTTP_REFERER']

I think thats the right one.

Posted: Sun May 23, 2004 3:40 pm
by rockindie
Steveo31 wrote:$_SERVER['HTTP_REFERER']

I think thats the right one.
nope, doesnt seem like it, i believe that will return like "google.com" if the user went to google.com then went to my site

Posted: Sun May 23, 2004 3:43 pm
by markl999
$_SERVER['HTTP_HOST']; with
$_SERVER['PHP_SELF'] or $_SERVER['REQUEST_URI'];

If you do a var_dump($_SERVER); you'll see the elements you can use to build up the current, full, url.

Posted: Sun May 23, 2004 3:44 pm
by rockindie
markl999 wrote:$_SERVER['HTTP_HOST']; with
$_SERVER['PHP_SELF'] or $_SERVER['REQUEST_URI'];

If you do a var_dump($_SERVER); you'll see the elements you can use to build up the current, full, url.
thanks, i found it just as you posted it to in the manual. has anyone else used a method like this to host 2 domains on one webserver

Posted: Sun May 23, 2004 3:47 pm
by markl999
has anyone else used a method like this to host 2 domains on one webserver
I use on sites such as dev.foo.com, beta.foo.com, alpha.foo.com etc.
I use :
define ('SITE', substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], '.')));

And SITE will be either dev, beta, alpha etc.. then i use that to get site specific configuration vars.