我有这个网站http://www.finalyearondesk.com。我的博客文章链接是这样设置的.. http://www.finalyearondesk.com/index.php?id=28。我希望它像这样设置... finalyearondesk.com/2011/09/22/how-to-recover-ubuntu-after-it-is-crashed/ 。
我正在使用以下功能来获取这些帖子...
function get_content($id = '') {
if($id != ""):
$id = mysql_real_escape_string($id);
$sql = "SELECT * from blog WHERE id = '$id'";
$return = '<p><a href="http://www.finalyearondesk.com/">Go back to Home page</a></p>';
echo $return;
else:
$sql = "select * from blog ORDER BY id DESC";
endif;
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) != 0):
while($row = mysql_fetch_assoc($res)) {
echo '<h1><a href="index.php?id=' . $row['id'] . '">' . $row['title'] . '</a></h1>';
echo '<p>' . "By: " . '<font color="orange">' . $row['author'] . '</font>' . ", Posted on: " . $row['date'] . '<p>';
echo '<p>' . $row['body'] . '</p><br />';
}
else:
echo '<p>We are really very sorry, this page does not exist!</p>';
endif;
}
任何建议如何做到这一点?我们可以通过使用 .htaccess 来做到这一点吗?