==== index.php ==== real_escape_string($_GET['url']); if (!trim($p)) goto nopage; $sql = 'SELECT url, id FROM red WHERE p = \'' . $p . '\' LIMIT 1'; $r = $m->query($sql); if (!$r) goto nopage; $a = $r->fetch_array(MYSQLI_NUM); if (!$a || count($a) != 2) goto nopage; $url = $a[0]; $m->query('UPDATE red SET count = count + 1 WHERE id = ' . $a[1] . ' LIMIT 1'); header('Location: ' . $url, true, 301); } else { nopage: header('Location: http://simon.geek.nz/', true, 302); } ==== .htaccess ==== RewriteEngine On RewriteCond %{REQUEST_URI} ^/(.*)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* index.php?url=%1&%{QUERY_STRING} [L] ==== Database schema ==== CREATE TABLE `red` ( `id` int(11) NOT NULL auto_increment, `p` varchar(255) NOT NULL, `url` varchar(1024) NOT NULL, `count` int(11) NOT NULL default '0', `last_access` timestamp NULL default NULL on update CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `page` (`p`) ) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=latin1; ==== License ==== http://sam.zoy.org/wtfpl/COPYING ==== Disclaimer ==== If using this cause bad things to happen, it's not my fault.