When i use this index.php on my hosting. this index.php for url shortner doesnt want to redirect the short url to main domain. Where is the problem? thx
The most important thing is that your host sends unknown pages back to the home page. Here is My working code. I wrote functions to to the lookups, but I dont want to post them, as they are common mysql statements. $curpage = curPageURL(); $isshort = dbcount("SELECT * FROM urls where shorturl='$curpage'") if ($isshort) { $su = $curpage; $result = selectdb("SELECT * FROM urls WHERE shorturl ='$su'"); while($row = mysql_fetch_array($result)) { $long = $row["longurl"]; } echo '<html><head>'; echo '<meta http-equiv="refresh" content="0;url='.$long.'">'; echo '</head><body></body></html>'; exit; } function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } $pageURL = str_replace('DOMAIN','',$pageURL); //Remove the http://domain.com return $pageURL; } PHP: