0) { # this entry has a title. # so we'll do an SQL query to find its id and redirect to correct archive page $sql = "select * from ease_posts where post_title = ‘$title’"; if ($res = mysql_query($sql)) { # get first row. If we didn’t find it, too bad. If there are multiple entries with same title, just use first entry. This can be improved. $row = mysql_fetch_array($res); # If it does't work experiment with the redirect statement below print "Redirect Permanent " . $mturl . PATH_TO_WP_SITE . "archives/" $mtdate . "/" . $row["ID"] . "/" . sanitize_title("$title"); } } else { # entry with no title # redirect to day page that contains all entries of that day. Not perfect but good enough. print "Redirect Permanent /ease/archives/00$mtentryid.html " . PATH_TO_WP_SITE . "archives/" . $mtdate . "/" ; } } // print "RewriteEngine On"; // Not really needed since you will just paste this into the existing htaccess file that already has RewriteEngine On writeit ("<$MTEntryTitle$>", "<$MTEntryID$>", "<$MTArchiveDate format="%Y/%m/%d"$>"); ?>