equal
deleted
inserted
replaced
16 * different URLs when they both go to the same location. This SEO enhancement |
16 * different URLs when they both go to the same location. This SEO enhancement |
17 * prevents penalty for duplicate content by redirecting all incoming links to |
17 * prevents penalty for duplicate content by redirecting all incoming links to |
18 * one or the other. |
18 * one or the other. |
19 * |
19 * |
20 * Prevents redirection for feeds, trackbacks, searches, comment popup, and |
20 * Prevents redirection for feeds, trackbacks, searches, comment popup, and |
21 * admin URLs. Does not redirect on IIS, page/post previews, and on form data. |
21 * admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7, |
|
22 * page/post previews, WP admin, Trackbacks, robots.txt, searches, or on POST |
|
23 * requests. |
22 * |
24 * |
23 * Will also attempt to find the correct link when a user enters a URL that does |
25 * Will also attempt to find the correct link when a user enters a URL that does |
24 * not exist based on exact WordPress query. Will instead try to parse the URL |
26 * not exist based on exact WordPress query. Will instead try to parse the URL |
25 * or query in an attempt to figure the correct page to go to. |
27 * or query in an attempt to figure the correct page to go to. |
26 * |
28 * |
35 * not needed or the string of the URL |
37 * not needed or the string of the URL |
36 */ |
38 */ |
37 function redirect_canonical( $requested_url = null, $do_redirect = true ) { |
39 function redirect_canonical( $requested_url = null, $do_redirect = true ) { |
38 global $wp_rewrite, $is_IIS, $wp_query, $wpdb; |
40 global $wp_rewrite, $is_IIS, $wp_query, $wpdb; |
39 |
41 |
40 if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || $is_IIS ) |
42 if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_IIS && !iis7_supports_permalinks() ) ) |
41 return; |
43 return; |
42 |
44 |
43 if ( !$requested_url ) { |
45 if ( !$requested_url ) { |
44 // build the URL in the address bar |
46 // build the URL in the address bar |
45 $requested_url = is_ssl() ? 'https://' : 'http://'; |
47 $requested_url = is_ssl() ? 'https://' : 'http://'; |
278 $redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path']; |
280 $redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path']; |
279 } |
281 } |
280 |
282 |
281 if ( 'wp-register.php' == basename( $redirect['path'] ) ) { |
283 if ( 'wp-register.php' == basename( $redirect['path'] ) ) { |
282 if ( is_multisite() ) |
284 if ( is_multisite() ) |
283 $redirect_url = apply_filters( 'wp_signup_location', site_url( 'wp-signup.php' ) ); |
285 $redirect_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); |
284 else |
286 else |
285 $redirect_url = site_url( 'wp-login.php?action=register' ); |
287 $redirect_url = site_url( 'wp-login.php?action=register' ); |
286 wp_redirect( $redirect_url, 301 ); |
288 wp_redirect( $redirect_url, 301 ); |
287 die(); |
289 die(); |
288 } |
290 } |