redirect_canonical WordPress Filter Hook
The redirect_canonical hook is used to redirect a visitor to the correct URL for a given page. This is useful for pages that have multiple URLs, such as when the www version of a URL is different from the non-www version. This hook is also useful for pages that are accessed through multiple URL schemes, such as http and https. By redirecting the visitor to the correct URL, you can ensure that they always access the page through the correct scheme.
apply_filters( 'redirect_canonical', string $redirect_url , string $requested_url ) #
Filters the canonical redirect URL.
Description
Returning false to this filter will cancel the redirect.
Parameters
- $redirect_url
(string)The redirect URL.
- $requested_url
(string)The requested URL.
Source
Changelog
Version | Description |
---|---|
2.3.0 | Introduced. |