Skip to content

Instantly share code, notes, and snippets.

@nagiyevelchin
Last active July 11, 2019 10:57
Show Gist options
  • Save nagiyevelchin/72595b09365cf5932e0dce1eeca47d4f to your computer and use it in GitHub Desktop.
Save nagiyevelchin/72595b09365cf5932e0dce1eeca47d4f to your computer and use it in GitHub Desktop.
ProcessWire multiple domain multiple language
<?php
//paste it in "site/ready.php" file
$wire->addHookAfter('Page::render', function (\ProcessWire\HookEvent $event) {
if (strpos(wire('config')->urls->httpRoot, '.com') !== false && wire('user')->language->name !== 'default') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".wire('page')->localHttpUrl('default'));
exit();
} elseif (strpos(wire('config')->urls->httpRoot, '.ru') !== false && wire('user')->language->name !== 'ru') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".wire('page')->localHttpUrl('ru'));
exit();
} elseif (strpos(wire('config')->urls->httpRoot, '.az') !== false && wire('user')->language->name !== 'az') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".wire('page')->localHttpUrl('az'));
exit();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment