Skip to content

Instantly share code, notes, and snippets.

@christianhaendel
Created June 11, 2016 15:12
Show Gist options
  • Save christianhaendel/e2d5bacd733aec6d491ec36a8d00c61d to your computer and use it in GitHub Desktop.
Save christianhaendel/e2d5bacd733aec6d491ec36a8d00c61d to your computer and use it in GitHub Desktop.
Enable Realurl to select individual errorPage
<?php
class user_pageNotFound {
function pageNotFound($params,$tsfeObj) {
global $TYPO3_CONF_VARS;
$url = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL').'index.php?id='.$TYPO3_CONF_VARS['EXTCONF']['realurl'][\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('HTTP_HOST')]['errorPage'];
$_buffer = $this->loadPage($url);
echo $_buffer;
}
function loadPage($url) {
$agent = "TYPO3 pageNotFoundFunction v1.0";
$header[] = "Accept: text/vnd.wap.wml,*.*";
$ch = curl_init($url);
if ($ch) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$tmp = curl_exec($ch);
if(FALSE == $tmp) {
print_r(curl_error($ch));
}
curl_close($ch);
}
return $tmp;
}
}
?>
@christianhaendel
Copy link
Author

Include 'pageNotFound_handling' => 'USER_FUNCTION:typo3conf/pageNotFoundHandling.php:user_pageNotFound->pageNotFound', in Localconfiguration.php FE section And setup in your realurl conf
$TYPO3_CONF_VARS['EXTCONF']['realurl']['domain.de']['errorPage']=PAGE_ID;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment