Skip to content

Instantly share code, notes, and snippets.

@hasenbalg
Created March 28, 2018 14:04
Show Gist options
  • Save hasenbalg/01d27f1dadc865d2efc45f1ca1819170 to your computer and use it in GitHub Desktop.
Save hasenbalg/01d27f1dadc865d2efc45f1ca1819170 to your computer and use it in GitHub Desktop.
Typo3 404 in chosen language
<?php
function logger($value)
{
$output = "\n" . print_r($value, TRUE) . "\n";
file_put_contents('php://stderr', $output);
//observe in apache log (tail -f /var/log/apache2/error.log)
}
// http://wiki.sklein-medien.de/doku.php?id=typo3:404
if (!defined('TYPO3_MODE')) {die('Access denied.');}
$GLOBALS ['TYPO3_CONF_VARS']['FE']['debug'] = true;
$languages = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['lang']['availableLanguages'];
$uri = $_SERVER['REQUEST_URI'];
logger($uri);
foreach ($languages as $l) {
$l = ($l == 'da') ? 'dk' : $l; //fix danish /da/
$pattern = '/\/' . $l . '\//';
if (preg_match($pattern, $uri)) {
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = ''.$l.'/404/';
}
}
logger($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment