suppose i have a : http://kanchan.com.np/events.php?event_id=1&image_id=20 http://www.kanchan.com.np/events.php?event_id=1&image_id=20 from this url i wanna remove off the main domain name and get the page info only.. i.e. : events.php?event_id=1&image_id=20 how is this done??
I believe that just returns the path itself, not the query portion of the url: Long way: $current_url = parse_url($_SERVER['REQUEST_URI']); $url_path = trim($current_url['path']); $url_query = trim($current_url['query']); $url_query = (!empty($url_query)) ? '?' .$url_query : $url_query; $url = $url_path .$url_query; PHP: Short way: $url_path = trim($_SERVER['PHP_SELF']); $url_query = trim($_SERVER['QUERY_STRING']); $url_query = (!empty($url_query)) ? '?' .$url_query : $url_query; $url = $url_path .$url_query; PHP:
$url = 'http://www.kanchan.com.np/events.php?id=1&image_id=20#test'; $info = parse_url($url); echo $info['path'].'?'.$info['query'].'#'.$info['fragment']; PHP: Peace,