Skip to content

Global redirect settings

If a post has a mapped domain the post would be accessible on both the mapped domain and the original URL. To avoid duplicate content issues the plugin redirects any requests made to resources on the main site that are configured to serve via a secondary domain.

👉🏻 e.g; If http://secondary.com/custom is mapped to http://primary.com/some-page, requests made to http://primary.com/some-page will be redirected to http://secondary.com/custom.

How to disable the post to domain redirect

  1. Head to Settings > WP Landing Kit.
  2. Find the Post Redirects settings.
  3. Uncheck the Redirect original posts to mapped domains checkbox.
  4. Hit Save Changes.

What happens when multiple URLs serve the same page?

As of version 1.1, it is possible to map multiple URLs to the same post/page/resource. If you are in a situation where you are serving the same resource across multiple domains/URLs, note the that first available URL found by the internal mapping functionality will be used to redirect.

Using the first mapped URL found ensures the most efficient functionality possible by saving on excessive database queries.

Special considerations for archive pages

  • If a request is made to a paginated page — e.g; http://example.com/people/page/2 — the redirect will take the user through to page 1 of the mapped domain/URL instead of the paginated equivalent.
  • If you are using WooCommerce and you have set up a mapping for a product post type archive, WC's shop page won't redirect through to the mapped page as it isn't a post type archive page.
  • The blog home page — targetable using is_home() — is redirected if a domain/URL is mapped to the post post type archive.

How to control the redirect URL and status

Before the redirect is executed, an array containing the redirect URL and status is passed through a filter offering developers the ability to modify these. The default status is 301.

👉🏻 Note that the callback is executed on the wp hook so that you can use WordPress' conditional tags to evaluate the current resource being requested.

How to change the status and/or URL

php
add_filter( 'wp_landing_kit/mapped_redirect_args', 'xyz_override_redirect_args' );
function xyz_override_redirect_args( $args ) {

	// Modify the URL
	$args['url'] = 'http://example.com';

	// Modify the status
	$args['status'] = 302;

	return $args;
}

How to disable the redirect

There might be times when you wish to disable a redirect in certain situations. You can do so by return false from the callback.

Be mindful that redirects — particularly those with a status of 301 — can be cached by browsers. If you disable a redirect after it is already live, you'll likely need to clear your browser's cache.

php
add_filter( 'wp_landing_kit/mapped_redirect_args', 'xyz_disable_redirect' );
function xyz_disable_redirect( $args ) {

	// Disable the redirect for page with ID 322
	if(is_page(322)){
		return false;
	}

	return $args;
}