$link->id = intval($_REQUEST['id']); } else { $link->id = intval($url_args[0]); } if ($id > 0 && $link->read()) { // Redirect to the right URL if the link has a "semantic" uri if (!empty($link->uri)) { header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $link->get_permalink()); die; } } else { not_found(); } } if ($link->is_discarded()) { // Dont allow indexing of discarded links if ($globals['bot']) { not_found(); } $globals['ads'] = false; } // Check for a page number which has to come to the end, i.e. ?id=xxx/P or /story/uri/P $last_arg = count($url_args) - 1; if ($last_arg > 0) { // Dirty trick to redirect to a comment' page if (preg_match('/^000/', $url_args[$last_arg])) { header('HTTP/1.1 301 Moved Permanently'); if ($url_args[$last_arg] > 0 && $url_args[$last_arg] <= $link->comments) { header('Location: ' . $link->get_permalink() . get_comment_page_suffix($globals['comments_page_size'], (int) $url_args[$last_arg], $link->comments) . '#c-' . (int) $url_args[$last_arg]); } else {