mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Canonical API to handle WordPress Redirecting
mp-wp_genesis 4 *
mp-wp_genesis 5 * Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference"
mp-wp_genesis 6 * by Mark Jaquith
mp-wp_genesis 7 *
mp-wp_genesis 8 * @author Scott Yang
mp-wp_genesis 9 * @author Mark Jaquith
mp-wp_genesis 10 * @package WordPress
mp-wp_genesis 11 * @since 2.3.0
mp-wp_genesis 12 */
mp-wp_genesis 13
mp-wp_genesis 14 /**
mp-wp_genesis 15 * Redirects incoming links to the proper URL based on the site url.
mp-wp_genesis 16 *
mp-wp_genesis 17 * Search engines consider www.somedomain.com and somedomain.com to be two
mp-wp_genesis 18 * different URLs when they both go to the same location. This SEO enhancement
mp-wp_genesis 19 * prevents penality for duplicate content by redirecting all incoming links to
mp-wp_genesis 20 * one or the other.
mp-wp_genesis 21 *
mp-wp_genesis 22 * Prevents redirection for feeds, trackbacks, searches, comment popup, and
mp-wp_genesis 23 * admin URLs. Does not redirect on IIS, page/post previews, and on form data.
mp-wp_genesis 24 *
mp-wp_genesis 25 * Will also attempt to find the correct link when a user enters a URL that does
mp-wp_genesis 26 * not exist based on exact WordPress query. Will instead try to parse the URL
mp-wp_genesis 27 * or query in an attempt to figure the correct page to go to.
mp-wp_genesis 28 *
mp-wp_genesis 29 * @since 2.3.0
mp-wp_genesis 30 * @uses $wp_rewrite
mp-wp_genesis 31 * @uses $is_IIS
mp-wp_genesis 32 *
mp-wp_genesis 33 * @param string $requested_url Optional. The URL that was requested, used to
mp-wp_genesis 34 * figure if redirect is needed.
mp-wp_genesis 35 * @param bool $do_redirect Optional. Redirect to the new URL.
mp-wp_genesis 36 * @return null|false|string Null, if redirect not needed. False, if redirect
mp-wp_genesis 37 * not needed or the string of the URL
mp-wp_genesis 38 */
mp-wp_genesis 39 function redirect_canonical($requested_url=null, $do_redirect=true) {
mp-wp_genesis 40 global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
mp-wp_genesis 41
mp-wp_genesis 42 if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() || is_robots() )
mp-wp_genesis 43 return;
mp-wp_genesis 44
mp-wp_genesis 45 if ( !$requested_url ) {
mp-wp_genesis 46 // build the URL in the address bar
mp-wp_genesis 47 $requested_url = ( !empty($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
mp-wp_genesis 48 $requested_url .= $_SERVER['HTTP_HOST'];
mp-wp_genesis 49 $requested_url .= $_SERVER['REQUEST_URI'];
mp-wp_genesis 50 }
mp-wp_genesis 51
mp-wp_genesis 52 $original = @parse_url($requested_url);
mp-wp_genesis 53 if ( false === $original )
mp-wp_genesis 54 return;
mp-wp_genesis 55
mp-wp_genesis 56 // Some PHP setups turn requests for / into /index.php in REQUEST_URI
mp-wp_genesis 57 // See: http://trac.wordpress.org/ticket/5017
mp-wp_genesis 58 // See: http://trac.wordpress.org/ticket/7173
mp-wp_genesis 59 // Disabled, for now:
mp-wp_genesis 60 // $original['path'] = preg_replace('|/index\.php$|', '/', $original['path']);
mp-wp_genesis 61
mp-wp_genesis 62 $redirect = $original;
mp-wp_genesis 63 $redirect_url = false;
mp-wp_genesis 64
mp-wp_genesis 65 // Notice fixing
mp-wp_genesis 66 if ( !isset($redirect['path']) ) $redirect['path'] = '';
mp-wp_genesis 67 if ( !isset($redirect['query']) ) $redirect['query'] = '';
mp-wp_genesis 68
mp-wp_genesis 69 if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) {
mp-wp_genesis 70
mp-wp_genesis 71 $vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) );
mp-wp_genesis 72
mp-wp_genesis 73 if ( isset($vars[0]) && $vars = $vars[0] ) {
mp-wp_genesis 74 if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )
mp-wp_genesis 75 $id = $vars->post_parent;
mp-wp_genesis 76
mp-wp_genesis 77 if ( $redirect_url = get_permalink($id) )
mp-wp_genesis 78 $redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id'), $redirect['query']);
mp-wp_genesis 79 }
mp-wp_genesis 80 }
mp-wp_genesis 81
mp-wp_genesis 82 // These tests give us a WP-generated permalink
mp-wp_genesis 83 if ( is_404() ) {
mp-wp_genesis 84 $redirect_url = redirect_guess_404_permalink();
mp-wp_genesis 85 } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
mp-wp_genesis 86 // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
mp-wp_genesis 87 if ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
mp-wp_genesis 88 if ( $redirect_url = get_permalink(get_query_var('p')) )
mp-wp_genesis 89 $redirect['query'] = remove_query_arg('p', $redirect['query']);
mp-wp_genesis 90 if ( get_query_var( 'page' ) ) {
mp-wp_genesis 91 $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
mp-wp_genesis 92 $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
mp-wp_genesis 93 }
mp-wp_genesis 94 } elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
mp-wp_genesis 95 if ( $redirect_url = get_permalink(get_query_var('page_id')) )
mp-wp_genesis 96 $redirect['query'] = remove_query_arg('page_id', $redirect['query']);
mp-wp_genesis 97 } elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
mp-wp_genesis 98 $m = get_query_var('m');
mp-wp_genesis 99 switch ( strlen($m) ) {
mp-wp_genesis 100 case 4: // Yearly
mp-wp_genesis 101 $redirect_url = get_year_link($m);
mp-wp_genesis 102 break;
mp-wp_genesis 103 case 6: // Monthly
mp-wp_genesis 104 $redirect_url = get_month_link( substr($m, 0, 4), substr($m, 4, 2) );
mp-wp_genesis 105 break;
mp-wp_genesis 106 case 8: // Daily
mp-wp_genesis 107 $redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
mp-wp_genesis 108 break;
mp-wp_genesis 109 }
mp-wp_genesis 110 if ( $redirect_url )
mp-wp_genesis 111 $redirect['query'] = remove_query_arg('m', $redirect['query']);
mp-wp_genesis 112 // now moving on to non ?m=X year/month/day links
mp-wp_genesis 113 } elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) {
mp-wp_genesis 114 if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) )
mp-wp_genesis 115 $redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
mp-wp_genesis 116 } elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) {
mp-wp_genesis 117 if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
mp-wp_genesis 118 $redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
mp-wp_genesis 119 } elseif ( is_year() && !empty($_GET['year']) ) {
mp-wp_genesis 120 if ( $redirect_url = get_year_link(get_query_var('year')) )
mp-wp_genesis 121 $redirect['query'] = remove_query_arg('year', $redirect['query']);
mp-wp_genesis 122 } elseif ( is_category() && !empty($_GET['cat']) ) {
mp-wp_genesis 123 if ( $redirect_url = get_category_link(get_query_var('cat')) )
mp-wp_genesis 124 $redirect['query'] = remove_query_arg('cat', $redirect['query']);
mp-wp_genesis 125 } elseif ( is_author() && !empty($_GET['author']) ) {
mp-wp_genesis 126 $author = get_userdata(get_query_var('author'));
mp-wp_genesis 127 if ( false !== $author && $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) )
mp-wp_genesis 128 $redirect['query'] = remove_query_arg('author', $redirect['author']);
mp-wp_genesis 129 }
mp-wp_genesis 130
mp-wp_genesis 131 // paging and feeds
mp-wp_genesis 132 if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
mp-wp_genesis 133 if ( !$redirect_url )
mp-wp_genesis 134 $redirect_url = $requested_url;
mp-wp_genesis 135 $paged_redirect = @parse_url($redirect_url);
mp-wp_genesis 136 while ( preg_match( '#/page/[0-9]+?(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $paged_redirect['path'] ) ) {
mp-wp_genesis 137 // Strip off paging and feed
mp-wp_genesis 138 $paged_redirect['path'] = preg_replace('#/page/[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing paging
mp-wp_genesis 139 $paged_redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+)?$#', '/', $paged_redirect['path']); // strip off feed endings
mp-wp_genesis 140 $paged_redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing comment paging
mp-wp_genesis 141 }
mp-wp_genesis 142
mp-wp_genesis 143 $addl_path = '';
mp-wp_genesis 144 if ( is_feed() ) {
mp-wp_genesis 145 $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
mp-wp_genesis 146 if ( get_query_var( 'withcomments' ) )
mp-wp_genesis 147 $addl_path .= 'comments/';
mp-wp_genesis 148 $addl_path .= user_trailingslashit( 'feed/' . ( ( 'rss2' == get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
mp-wp_genesis 149 $redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
mp-wp_genesis 150 }
mp-wp_genesis 151
mp-wp_genesis 152 if ( get_query_var('paged') > 0 ) {
mp-wp_genesis 153 $paged = get_query_var('paged');
mp-wp_genesis 154 $redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
mp-wp_genesis 155 if ( !is_feed() ) {
mp-wp_genesis 156 if ( $paged > 1 && !is_single() ) {
mp-wp_genesis 157 $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("page/$paged", 'paged');
mp-wp_genesis 158 } elseif ( !is_single() ) {
mp-wp_genesis 159 $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit($paged_redirect['path'], 'paged');
mp-wp_genesis 160 }
mp-wp_genesis 161 } elseif ( $paged > 1 ) {
mp-wp_genesis 162 $redirect['query'] = add_query_arg( 'paged', $paged, $redirect['query'] );
mp-wp_genesis 163 }
mp-wp_genesis 164 }
mp-wp_genesis 165
mp-wp_genesis 166 if ( get_option('page_comments') && ( ( 'newest' == get_option('default_comments_page') && get_query_var('cpage') > 0 ) || ( 'newest' != get_option('default_comments_page') && get_query_var('cpage') > 1 ) ) ) {
mp-wp_genesis 167 $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( 'comment-page-' . get_query_var('cpage'), 'commentpaged' );
mp-wp_genesis 168 $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] );
mp-wp_genesis 169 }
mp-wp_genesis 170
mp-wp_genesis 171 $paged_redirect['path'] = user_trailingslashit( preg_replace('|/index.php/?$|', '/', $paged_redirect['path']) ); // strip off trailing /index.php/
mp-wp_genesis 172 if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false )
mp-wp_genesis 173 $paged_redirect['path'] = trailingslashit($paged_redirect['path']) . 'index.php/';
mp-wp_genesis 174 if ( !empty( $addl_path ) )
mp-wp_genesis 175 $paged_redirect['path'] = trailingslashit($paged_redirect['path']) . $addl_path;
mp-wp_genesis 176 $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path'];
mp-wp_genesis 177 $redirect['path'] = $paged_redirect['path'];
mp-wp_genesis 178 }
mp-wp_genesis 179 }
mp-wp_genesis 180
mp-wp_genesis 181 // tack on any additional query vars
mp-wp_genesis 182 $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
mp-wp_genesis 183 if ( $redirect_url && !empty($redirect['query']) ) {
mp-wp_genesis 184 if ( strpos($redirect_url, '?') !== false )
mp-wp_genesis 185 $redirect_url .= '&';
mp-wp_genesis 186 else
mp-wp_genesis 187 $redirect_url .= '?';
mp-wp_genesis 188 $redirect_url .= $redirect['query'];
mp-wp_genesis 189 }
mp-wp_genesis 190
mp-wp_genesis 191 if ( $redirect_url )
mp-wp_genesis 192 $redirect = @parse_url($redirect_url);
mp-wp_genesis 193
mp-wp_genesis 194 // www.example.com vs example.com
mp-wp_genesis 195 $user_home = @parse_url(get_option('home'));
mp-wp_genesis 196 if ( !empty($user_home['host']) )
mp-wp_genesis 197 $redirect['host'] = $user_home['host'];
mp-wp_genesis 198 if ( empty($user_home['path']) )
mp-wp_genesis 199 $user_home['path'] = '/';
mp-wp_genesis 200
mp-wp_genesis 201 // Handle ports
mp-wp_genesis 202 if ( !empty($user_home['port']) )
mp-wp_genesis 203 $redirect['port'] = $user_home['port'];
mp-wp_genesis 204 else
mp-wp_genesis 205 unset($redirect['port']);
mp-wp_genesis 206
mp-wp_genesis 207 // trailing /index.php
mp-wp_genesis 208 $redirect['path'] = preg_replace('|/index.php/*?$|', '/', $redirect['path']);
mp-wp_genesis 209
mp-wp_genesis 210 // Remove trailing spaces from the path
mp-wp_genesis 211 $redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
mp-wp_genesis 212
mp-wp_genesis 213 if ( !empty( $redirect['query'] ) ) {
mp-wp_genesis 214 // Remove trailing spaces from certain terminating query string args
mp-wp_genesis 215 $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
mp-wp_genesis 216
mp-wp_genesis 217 // Clean up empty query strings
mp-wp_genesis 218 $redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
mp-wp_genesis 219
mp-wp_genesis 220 // Remove redundant leading ampersands
mp-wp_genesis 221 $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
mp-wp_genesis 222 }
mp-wp_genesis 223
mp-wp_genesis 224 // strip /index.php/ when we're not using PATHINFO permalinks
mp-wp_genesis 225 if ( !$wp_rewrite->using_index_permalinks() )
mp-wp_genesis 226 $redirect['path'] = str_replace('/index.php/', '/', $redirect['path']);
mp-wp_genesis 227
mp-wp_genesis 228 // trailing slashes
mp-wp_genesis 229 if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) {
mp-wp_genesis 230 $user_ts_type = '';
mp-wp_genesis 231 if ( get_query_var('paged') > 0 ) {
mp-wp_genesis 232 $user_ts_type = 'paged';
mp-wp_genesis 233 } else {
mp-wp_genesis 234 foreach ( array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type ) {
mp-wp_genesis 235 $func = 'is_' . $type;
mp-wp_genesis 236 if ( call_user_func($func) ) {
mp-wp_genesis 237 $user_ts_type = $type;
mp-wp_genesis 238 break;
mp-wp_genesis 239 }
mp-wp_genesis 240 }
mp-wp_genesis 241 }
mp-wp_genesis 242 $redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type);
mp-wp_genesis 243 } elseif ( is_front_page() ) {
mp-wp_genesis 244 $redirect['path'] = trailingslashit($redirect['path']);
mp-wp_genesis 245 }
mp-wp_genesis 246
mp-wp_genesis 247 // Always trailing slash the Front Page URL
mp-wp_genesis 248 if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) )
mp-wp_genesis 249 $redirect['path'] = trailingslashit($redirect['path']);
mp-wp_genesis 250
mp-wp_genesis 251 // Ignore differences in host capitalization, as this can lead to infinite redirects
mp-wp_genesis 252 // Only redirect no-www <=> yes-www
mp-wp_genesis 253 if ( strtolower($original['host']) == strtolower($redirect['host']) ||
mp-wp_genesis 254 ( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
mp-wp_genesis 255 $redirect['host'] = $original['host'];
mp-wp_genesis 256
mp-wp_genesis 257 $compare_original = array($original['host'], $original['path']);
mp-wp_genesis 258
mp-wp_genesis 259 if ( !empty( $original['port'] ) )
mp-wp_genesis 260 $compare_original[] = $original['port'];
mp-wp_genesis 261
mp-wp_genesis 262 if ( !empty( $original['query'] ) )
mp-wp_genesis 263 $compare_original[] = $original['query'];
mp-wp_genesis 264
mp-wp_genesis 265 $compare_redirect = array($redirect['host'], $redirect['path']);
mp-wp_genesis 266
mp-wp_genesis 267 if ( !empty( $redirect['port'] ) )
mp-wp_genesis 268 $compare_redirect[] = $redirect['port'];
mp-wp_genesis 269
mp-wp_genesis 270 if ( !empty( $redirect['query'] ) )
mp-wp_genesis 271 $compare_redirect[] = $redirect['query'];
mp-wp_genesis 272
mp-wp_genesis 273 if ( $compare_original !== $compare_redirect ) {
mp-wp_genesis 274 $redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
mp-wp_genesis 275 if ( !empty($redirect['port']) )
mp-wp_genesis 276 $redirect_url .= ':' . $redirect['port'];
mp-wp_genesis 277 $redirect_url .= $redirect['path'];
mp-wp_genesis 278 if ( !empty($redirect['query']) )
mp-wp_genesis 279 $redirect_url .= '?' . $redirect['query'];
mp-wp_genesis 280 }
mp-wp_genesis 281
mp-wp_genesis 282 if ( !$redirect_url || $redirect_url == $requested_url )
mp-wp_genesis 283 return false;
mp-wp_genesis 284
mp-wp_genesis 285 // Note that you can use the "redirect_canonical" filter to cancel a canonical redirect for whatever reason by returning FALSE
mp-wp_genesis 286 $redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
mp-wp_genesis 287
mp-wp_genesis 288 if ( !$redirect_url || $redirect_url == $requested_url ) // yes, again -- in case the filter aborted the request
mp-wp_genesis 289 return false;
mp-wp_genesis 290
mp-wp_genesis 291 if ( $do_redirect ) {
mp-wp_genesis 292 // protect against chained redirects
mp-wp_genesis 293 if ( !redirect_canonical($redirect_url, false) ) {
mp-wp_genesis 294 wp_redirect($redirect_url, 301);
mp-wp_genesis 295 exit();
mp-wp_genesis 296 } else {
mp-wp_genesis 297 // Debug
mp-wp_genesis 298 // die("1: $redirect_url<br />2: " . redirect_canonical( $redirect_url, false ) );
mp-wp_genesis 299 return false;
mp-wp_genesis 300 }
mp-wp_genesis 301 } else {
mp-wp_genesis 302 return $redirect_url;
mp-wp_genesis 303 }
mp-wp_genesis 304 }
mp-wp_genesis 305
mp-wp_genesis 306 /**
mp-wp_genesis 307 * Attempts to guess correct post based on query vars.
mp-wp_genesis 308 *
mp-wp_genesis 309 * @since 2.3.0
mp-wp_genesis 310 * @uses $wpdb
mp-wp_genesis 311 *
mp-wp_genesis 312 * @return bool|string Returns False, if it can't find post, returns correct
mp-wp_genesis 313 * location on success.
mp-wp_genesis 314 */
mp-wp_genesis 315 function redirect_guess_404_permalink() {
mp-wp_genesis 316 global $wpdb;
mp-wp_genesis 317
mp-wp_genesis 318 if ( !get_query_var('name') )
mp-wp_genesis 319 return false;
mp-wp_genesis 320
mp-wp_genesis 321 $where = $wpdb->prepare("post_name LIKE %s", get_query_var('name') . '%');
mp-wp_genesis 322
mp-wp_genesis 323 // if any of year, monthnum, or day are set, use them to refine the query
mp-wp_genesis 324 if ( get_query_var('year') )
mp-wp_genesis 325 $where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
mp-wp_genesis 326 if ( get_query_var('monthnum') )
mp-wp_genesis 327 $where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
mp-wp_genesis 328 if ( get_query_var('day') )
mp-wp_genesis 329 $where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
mp-wp_genesis 330
mp-wp_genesis 331 $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'");
mp-wp_genesis 332 if ( !$post_id )
mp-wp_genesis 333 return false;
mp-wp_genesis 334 return get_permalink($post_id);
mp-wp_genesis 335 }
mp-wp_genesis 336
mp-wp_genesis 337 add_action('template_redirect', 'redirect_canonical');
mp-wp_genesis 338
mp-wp_genesis 339 ?>