maybe_redirect_404()404页面NOBLOGREDIRECT设置(多站点)

目录

描述

Applies only for WordPress Multisite installation.

Correct 404 redirects when NOBLOGREDIRECT is defined.

maybe_redirect_404() 描述

用法

<?php maybe_redirect_404() ?>

maybe_redirect_404() 用法

参数

This function does not accept any parameters.

maybe_redirect_404() 参数

示例

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

maybe_redirect_404() 示例

注意

If registration is disabled, please set NOBLOGREDIRECT in wp-config.php to a URL you will redirect visitors to if they visit a non-existent site:

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

define( 'NOBLOGREDIRECT', '%siteurl%' );

or

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

define( 'NOBLOGREDIRECT', 'http://www.my-ms.com' );

maybe_redirect_404() 注意

历史

添加于 版本: MU

maybe_redirect_404() 历史

源文件

maybe_redirect_404() 函数的代码位于 wp-includes/ms-functions.php

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Correct 404 redirects when NOBLOGREDIRECT is defined.
 *
 * @since MU
 */
function maybe_redirect_404() {
	/**
	 * Filter the redirect URL for 404s on the main site.
	 *
	 * The filter is only evaluated if the NOBLOGREDIRECT constant is defined.
	 *
	 * @since 3.0.0
	 *
	 * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT.
	 */
	if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
		if ( $destination == '%siteurl%' )
			$destination = network_home_url();
		wp_redirect( $destination );
		exit();
	}
}

maybe_redirect_404() 源文件

相关