Hi can extract from a url the base url ? Example http://www.demourl.com/test1/test2 and I want to extract http://www.demourl.com/ Also how can I detect languge of url?
what do u mean by extract if you mean you want to http://www.demourl.com/test1/test2 over here http://www.demourl.com/ then use php include or iframes
The OP simply wants to get rid of the "/test1/test2" in a given domain name. So he/she is left with the name domain name "example.com". I have tried to come up with something to do that, but I'm having a little difficulty.
$url = 'http://www.demourl.com/test1/test2'; $parts = parse_url($url); echo 'http://' . $parts['host'] . '/'; PHP:
<?php // get host name from URL preg_match('@^(?:http://)?([^/]+)@i', "http://www.php.net/index.html", $matches); $host = $matches[1]; // get last two segments of host name preg_match('/[^.]+\.[^.]+$/', $host, $matches); echo "domain name is: {$matches[0]}\n"; ?> PHP: The above example will output: domain name is: php.net