Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AubreyHewes/b80413959767a73c0291510722ce5c9e to your computer and use it in GitHub Desktop.
Save AubreyHewes/b80413959767a73c0291510722ce5c9e to your computer and use it in GitHub Desktop.
WordPress "Multiple Domain" & WPML compatability fix
/**
* Configured "Multiple Domain" plugin does not redirect root properly when working with WPML...
*
* X.nl -> /
* Y.nl -> /
* X.com -> /en/
* Y.com -> /en/
*/
function fix_multiple_domain_plugin_redirects() {
if (strpos(MULTIPLE_DOMAIN_DOMAIN, '.com') === false) {
return;
}
if (is_home() || is_front_page() || empty($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] === '/') {
wp_redirect(home_url() . '/en/');
exit;
}
}
add_action('init', 'fix_multiple_domain_plugin_redirects', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment