0) { // Parse the url to preserve the fragment. $pieces = parse_url($url); if (isset($pieces['fragment'])) { $url = str_replace('#' . $pieces['fragment'], '', $url); } // Handle additional query string params. if ($query_string) { if (stristr($url, '?')) { $url .= '&' . $query_string; } else { $url .= '?' . $query_string; } } // slap the fragment onto the end per URL spec if (isset($pieces['fragment'])) { $url .= '#' . $pieces['fragment']; } } CRM_Utils_System::redirect($url);