[EMAIL PROTECTED] wrote:
>
>
> ----- Original Message -----
> From: "Leelakh Ran"
>
> Hi everybody,
>
> My site URL showing as
> http://www.sub.mysite.com/onetwothree.htm?get=name
> <http://www.sub.mysite.com/onetwothree.htm?get=name>
>
> I can access this URL on following ways.
>
> $urlfullget = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
> $urlsub = $_SERVER["HTTP_HOST"]
>
> Here, variable $urlfullget will store as =
> www.sub.mysite.com/onetwothree.htm?get=name
>
> and
>
> variable $urlsub will store as = www.sub.mysite.com
>
> But I want to store these data.
>
> 1) www.sub.mysite.com/onetwothree.htm
> 2) mysite.com
>
> (If URL changed, stored data should change accordingly)
>
> So, how it can store on $urlfull & $urlmain respectively.
>
> Expecting experts' precious support on this matter.
>
> With thanks in advance,
>
> Rgds, Leelakh Ran.
>
> ------------------------------------
>
> $url = 'http://username:[EMAIL PROTECTED]/path?arg=value#anchor
> <http://username:[EMAIL PROTECTED]/path?arg=value#anchor>';
>
> parse_url($url) =
> Array
> (
> [scheme] => http
> [host] => hostname
> [user] => username
> [pass] => password
> [path] => /path
> [query] => arg=value
> [fragment] => anchor
> )
>
> http://au2.php.net/manual/en/function.parse-url.php
> <http://au2.php.net/manual/en/function.parse-url.php>
>
I don't think that parse_url is going to split this up the way you want
either. Although there may be a function that I'm not aware of, I would
do the following:
<?php
$url = 'www.sub.mysite.com/onetwothree.htm?get=name';
preg_match("#^[^/]*#",$url,$fullurl);
preg_match("#.+?\.(\w+\.\w{2,4})$#",$fullurl[0],$domain);
$urlfullget = $fullurl[0];
$urlsub = $domain[1];
?>
William Piper