I am having some issues with PHP detecting http:// containing and non-http:// containing links from database and referencing user based on them here is the code;
$url = $_GET['short'];
$route_url = mysql_result(mysql_query('SELECT original_url FROM ' . DB_TABLE . ' WHERE short_url = "' . mysql_real_escape_string($url) . '"'));
mysql_query('UPDATE ' . DB_TABLE . ' SET refferals = refferals + 1 WHERE short_url = "' . mysql_real_escape_string($url) . '"');
if(preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i", $route_url)) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $route_url);
} else {
$protocol = "http://";
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $protocol.$route_url);
}
mysql_close();
exit;
Can some on tell me what I am doing wrong and how to fix it, so both http:// and non-http:// (google.com) work with redirect