Thanks for the responses.
In the end i've just removed the sanitisation as this was unnecessary since I'm not executing the query string values anywhere on the site.
Final code as follows:
if ($detect->isMobile()) {
// set query string:
$query_string = $_SERVER['QUERY_STRING'];
// if query string empty send to mobile site, else send to mobile site and concatenate query string:
if (empty($query_string)) {
header('Location: http://m.mywebsite.com/');
exit;
} else {
header('Location: http://m.mywebsite.com/?'. $query_string);
exit;
}
}