You appear to be a bot. Output may be restricted
Description
Checks whether the current request needs to be redirected to sitemap_index.xml.
Usage
$bool = WPSEO_Sitemaps_Router::needs_sitemap_index_redirect();
Parameters
Returns
bool True if redirect is needed, false otherwise.
Source
File name: wordpress-seo/inc/sitemaps/class-sitemaps-router.php
Lines:
1 to 26 of 26
public function needs_sitemap_index_redirect() { global $wp_query; $protocol = 'http://'; if ( ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ) { $protocol = 'https://'; } $domain = ''; if ( isset( $_SERVER['SERVER_NAME'] ) ) { $domain = sanitize_text_field( wp_unslash( $_SERVER['SERVER_NAME'] ) ); } $path = ''; if ( isset( $_SERVER['REQUEST_URI'] ) ) { $path = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ); } // Due to different environment configurations, we need to check both SERVER_NAME and HTTP_HOST. $check_urls = [ $protocol . $domain . $path ]; if ( ! empty( $_SERVER['HTTP_HOST'] ) ) { $check_urls[] = $protocol . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) . $path; } return $wp_query->is_404 && in_array( home_url( '/sitemap.xml' ), $check_urls, true ); }