$this->canonicalURL = LinkHandler::getInstance()->getCmsLink($this->pageID, $this->languageID);
if ($this->page->isMultilingual && RequestHandler::getInstance()->getActiveRequest()->getMetaData()['isDefaultController']) {
- if ($this->languageID != LanguageFactory::getInstance()->getDefaultLanguageID()) {
- $this->softRedirectCanonicalURL = true;
- }
+ $this->softRedirectCanonicalURL = true;
}
// update interface language
else if (preg_match('~^__WCF_CMS__(?P<pageID>\d+)$~', $controller, $matches)) {
$cmsPageData = $this->lookupCmsPage($matches['pageID'], 0);
if ($cmsPageData === null) {
- // page is multilingual, use current language id to resolve request
- $cmsPageData = $this->lookupCmsPage($matches['pageID'], WCF::getLanguage()->languageID);
+ // page is multilingual, use the language id that matches the URL
+ // do *not* use the client language id, Google's bot is stubborn
+ $languageID = null;
+ // use a reverse search to find the page
+ if (isset($this->customUrls['lookup']['wcf']) && isset($this->customUrls['lookup']['wcf']['']) && preg_match('~^__WCF_CMS__\d+\-(?P<languageID>\d+)$~', $this->customUrls['lookup']['wcf'][''], $match)) {
+ $languageID = $match['languageID'];
+ }
+
+ if ($languageID === null) {
+ // something went wrong, use the current language id
+ $languageID = WCF::getLanguage()->languageID;
+ }
+
+ $cmsPageData = $this->lookupCmsPage($matches['pageID'], $languageID);
if ($cmsPageData === null) {
throw new SystemException("Unable to resolve CMS page");
}