Skip to content

Handling requests made to inactive or non-existent domains

You may find yourself in a situation where you need to handle requests made via domains that don't exist or are inactive.

To do so, you may use the wp_landing_kit/unmapped_domain_requested action hook.

php
add_action('wp_landing_kit/unmapped_domain_requested', 'xzy_handle_unmapped_domain');

function xzy_handle_unmapped_domain($host){

		// Example 1: Log the unmatched host name as an error.
		trigger_error("Domain host not found: $host");

		// Example 2: Redirect a particular host name.
		if($host === 'draft-domain.com'){
				wp_redirect('http://example.com')
		}

}

When is this hook triggered?

The action hook is fired in the following circumstances:

  1. The plugin cannot find a domain record for the host name requested.
  2. The domain found matching the requested host name does not have a status of publish.