Created
April 4, 2013 10:17
-
-
Save typeofweb/5309306 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
<? | |
/* | |
Template Name: XML Template | |
*/ | |
$qry = $wpdb->get_results(" | |
SELECT SUBSTR( | |
CONCAT( | |
REPLACE( | |
REPLACE( | |
REPLACE( | |
REPLACE(wpo.option_value,'%year%',date_format(wpp.post_date,'%Y')) | |
,'%monthnum%',date_format(wpp.post_date,'%m')) | |
,'%day%',date_format(wpp.post_date,'%d')) | |
,'%postname%',wpp.post_name ) | |
) | |
, 2) as permalink FROM wp_posts wpp INNER JOIN wp_options wpo on wpo.option_name='permalink_structure' WHERE wpp.post_type = 'post' AND wpp.post_status = 'publish' ORDER BY wpp.post_date DESC"); | |
$ret = ""; | |
foreach ($qry as $it) { | |
$ret .= 'RewriteCond %{HTTP_HOST} ^olddomain.com [NC]' . "\n"; | |
$ret .= 'RewriteRule ^' . $it->permalink . '$ http://newdomain.com/' . $it->permalink . " [R=301,L]\n"; | |
} | |
header("Content-Type: text/plain"); | |
echo $ret; | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment