Last active
July 11, 2019 10:57
-
-
Save nagiyevelchin/72595b09365cf5932e0dce1eeca47d4f to your computer and use it in GitHub Desktop.
ProcessWire multiple domain multiple language
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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