Forum Moderators: phranque
http://www.sitename.com/YYYYMMDD-the-title-slug/ http://www.newdomain.com/site-name/YYYY/MM/DD/the-title-slug/ http://www.sitename.com/YYYY/MM/the-title-slug.html/ http://www.newdomain.com/site-name/YYYY/MM/DD/the-title-slug/ Options +FollowSymLinks
RewriteEngine on
RewriteRule ([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])-([^/]+)/ http://www.rantsports.com/new-york-islanders/$1/$2/$3/$4/ [R=301,L] <?php
$post_obj = $wp_query->get_queried_object();
$post_ID = $post_obj->ID;
$post_title = $post_obj->post_title;
$post_slug = $post_obj->post_name;
$post_date = $wpdp->get_results("SELECT post_date FROM $wpdb->posts WHERE post_title = $post_slug");
list($y, $m, $d) = explode('-', substr($post_date, 0, 9));
$new_url = 'http://www.example.com/TEAM-NAME/'.$y.'/'.$m.'/'.$d.'/'.$post_slug.'/';
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: ".$new_url." );
?>
I just checked it again though and for some reason every time I save the .htaccess file its removing the redirect rules...
<?php
$post_obj = $wp_query->get_queried_object();
$post_ID = $post_obj->ID;
$post_title = $post_obj->post_title;
$post_slug = $post_obj->post_name;
$post_date = $wpdp->get_results("SELECT post_date FROM wp_posts WHERE post_title = '$post_slug'");
list($y, $m, $d) = explode('-', substr($post_date, 0, 9));
$new_url = 'http://www.example.com/TEAM-NAME/'.$y.'/'.$m.'/'.$d.'/'.$post_slug.'/';
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: ".$new_url."" );
?>