redirect_canonical


redirect_canonical ( $requested_url = null, $do_redirect = true )

Parameters:
  • (string) requested_url Optional. The URL that was requested, used to figure if redirect is needed.
  • (bool) do_redirect Optional. Redirect to the new URL.
Returns:
  • (string|void) The string of the URL, if redirect needed.
Defined at:

Description

Redirects incoming links to the proper URL based on the site url.Search engines consider www.somedomain.com and somedomain.com to be two different URLs when they both go to the same location. This SEO enhancement prevents penalty for duplicate content by redirecting all incoming links to one or the other. Prevents redirection for feeds, trackbacks, searches, and admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7+, page/post previews, WP admin, Trackbacks, robots.txt, favicon.ico, searches, or on POST requests. Will also attempt to find the correct link when a user enters a URL that does not exist based on exact WordPress query. Will instead try to parse the URL or query in an attempt to figure the correct page to go to.

Related Functions

rel_canonical, redirect_post, wp_get_canonical_url, wp_admin_canonical_url, wp_redirect_admin_locations

Top Google Results

User discussions

wpseek mobile