| 2 | | // Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference" by Mark Jaquith |
|---|
| 3 | | |
|---|
| 4 | | function redirect_canonical($requested_url=NULL, $do_redirect=true) { |
|---|
| | 2 | /** |
|---|
| | 3 | * Canonical API to handle WordPress Redirecting |
|---|
| | 4 | * |
|---|
| | 5 | * Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference" by Mark Jaquith |
|---|
| | 6 | * |
|---|
| | 7 | * @author Scott Yang |
|---|
| | 8 | * @author Mark Jaquith |
|---|
| | 9 | * @package WordPress |
|---|
| | 10 | * @since 2.3 |
|---|
| | 11 | */ |
|---|
| | 12 | |
|---|
| | 13 | /** |
|---|
| | 14 | * redirect_canonical() - Redirects incoming links to the proper URL based on the site url |
|---|
| | 15 | * |
|---|
| | 16 | * Search engines consider www.somedomain.com and somedomain.com to be two different URLs |
|---|
| | 17 | * when they both go to the same location. This SEO enhancement prevents penality for |
|---|
| | 18 | * duplicate content by redirecting all incoming links to one or the other. |
|---|
| | 19 | * |
|---|
| | 20 | * Prevents redirection for feeds, trackbacks, searches, comment popup, and admin URLs. |
|---|
| | 21 | * Does not redirect on IIS, page/post previews, and on form data. |
|---|
| | 22 | * |
|---|
| | 23 | * Will also attempt to find the correct link when a user enters a URL that does not exist |
|---|
| | 24 | * based on exact WordPress query. Will instead try to parse the URL or query in an attempt |
|---|
| | 25 | * to figure the correct page to go to. |
|---|
| | 26 | * |
|---|
| | 27 | * @since 2.3 |
|---|
| | 28 | * @uses $wp_rewrite |
|---|
| | 29 | * @uses $is_IIS |
|---|
| | 30 | * |
|---|
| | 31 | * @param string $requested_url Optional. The URL that was requested, used to figure if redirect is needed. |
|---|
| | 32 | * @param bool $do_redirect Optional. Redirect to the new URL. |
|---|
| | 33 | * @return null|false|string Null, if redirect not needed. False, if redirect not needed or the string of the URL |
|---|
| | 34 | */ |
|---|
| | 35 | function redirect_canonical($requested_url=null, $do_redirect=true) { |
|---|