Created
January 4, 2009 12:39
-
-
Save yoshuki/43044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** WordPressの設定ファイル */ | |
require_once('wp-config.php'); | |
$db = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); | |
mysql_select_db(DB_NAME, $db); | |
$sql = "SELECT post_date, post_name FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC"; | |
$result = mysql_query($sql, $db); | |
while ($row = mysql_fetch_assoc($result)) { | |
$pn = $row['post_name']; | |
$pd = strtotime($row['post_date']); | |
// パスのみ | |
$from = '/weblog/' . date('Y/m/', $pd) . $pn . '.html'; | |
// フルURL | |
$to = 'http://example.com/weblog/' . date('/Y/m/d/His', $pd) . '.html'; | |
echo 'Redirect permanent ' . $from . ' ' . $to . "\n"; | |
} | |
mysql_close($db); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment